This question already has an answer here:
I'm new to PHP and Laravel so perhaps I'm doing something wrong. I'm following along to Jeffrey Way's Laracasts tutorials and he creates a "query scope" method.
When I then use that in my controller, it says it cant find it.
In my Task model I have:
public static function scopeCompleted( Builder $query )
{
return $query->where( 'completed', 1 );
}
In my controller I have:
$completed_tasks = Task::completed()->get();
but completed
is highlighted by PhpStorm with the error:
"Method 'completed' not found in App\Task"
I know it's looking for a method called scopeCompleted
, but this is not how you call a query scope method in the controller.
Am I doing something wrong or is this just a flaw in PhpStorm?
FYI: the code functions perfectly well.
</div>