Level 36
Hello -
Local scope methods shouldn't be static:
public function scopeFirstUser($query)
{
return $query->where('id', 1);
}
This is really strange:
in my User.php I have (sample scope):
public static function scopeFirstUser($query) {
return $query->where('id', 1);
}
I tried with/without static; the result is the same.
When I try \App\User::firstUser()->get() I get this error:
(1/1) BadMethodCallException
Call to undefined method Illuminate\Database\Query\Builder::firstUser()
But when I copy the scope function to another model like Order.php, \App\Order::firstUser()->get()works fine!!!
Please or to participate in this conversation.