Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shadrix's avatar
Level 12

How does it work? Eloquent Models can be called statically and non static.

I'm curious how can I write a code like that? Because with Eloquent I can call these like that:

Model::find(1);

Or

$a = new Model();
$a->find(1);

Now I want to have the same method name as well because I'm stuck with

  public static function uncompleted(){}
  public function uncompleted() {} //not working
0 likes
1 reply
lostdreamer_nl's avatar
Level 53

You can call static methods contextually as well ;)

Just create the static method and do not use $this within the method. If you need access to private / protected contextual methods within the static one, start the method with:

$concrete = new static();
$concrete->publicFunctionYouNeedToCall();
1 like

Please or to participate in this conversation.