Laravel - Getting Started - Dynamic Scopes

Sometimes you may wish to define a scope that accepts parameters. To get started, just add your additional parameters to your scope method's signature. Scope parameters should be defined after the $query parameter:

    where('type', $type);

Once the expected arguments have been added to your scope method's signature, you may pass the arguments when calling the scope:

    $users = User::ofType('admin')->get();