Skip to content

Instantly share code, notes, and snippets.

View EricMcWinNer's full-sized avatar
😴
Sleeping... If it's important, dream it to me

Eric Aprioku (Eric McWinNEr) EricMcWinNer

😴
Sleeping... If it's important, dream it to me
View GitHub Profile
<?php
class A {
public function nonStaticMethod(){
echo "I am non-static";
}
public static function staticMethod() {
echo "I am static" . self::nonStaticMethod(); // Throws error: Non-static method cannot be called statically
}
<?php
class A {
public static function staticMethod() {
echo "I am static";
}
public function nonStaticMethod() {
echo "I am not static" . self::staticMethod(); // This works nicely.
}
<?php
class A {
public function staticMethod() {
echo get_class($this);
}
public function otherStaticMethod() {
self::staticMethod(); // This runs nicely. We can use self:: to access static methods from other static methods.
}
<?php
class Animal {
public static function makeSound(){
echo "Animal";
}
public static function vocalize() {
echo self::makeSound();
}
<?php
namespace App\Http\Controllers\Employer\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\User;
class HomeController extends Controller
{
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The booted method of the model
<?php
namespace App\Http\Controllers\Employer\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\User;
class HomeController extends Controller
{
<?php
namespace App\Http\Controllers\Employer\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\User;
class HomeController extends Controller
{
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The attributes that should be cast.
<?php
namespace App\Http\Controllers\Employer\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\User;
class HomeController extends Controller
{