Laravel - Getting Started - Utilizing A Local Scope

Once the scope has been defined, you may call the scope methods when querying the model. However, you should not include the scope prefix when calling the method. You can even chain calls to various scopes:

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

Combining multiple Eloquent model scopes via an or query operator may require the use of closures to achieve the correct logical grouping:

    
    $users = User::popular()->orWhere(function (Builder $query) {
        $query->active();
    })->get();
	

However, since this can be cumbersome, Laravel provides a "higher order" orWhere method that allows you to fluently chain scopes together without the use of closures:

    
    $users = App\Models\User::popular()->orWhere->active()->get();