0 votes
in Laravel by
What are query scopes?

1 Answer

0 votes
by
Local scopes allow you to define common sets of constraints that you may easily re-use throughout your application.

public function scopePopular($query)

{

return $query->where('votes', '>', 100);

}

Consider:

$users = App\User::popular()->active()->orderBy('created_at')->get();
...