Laravel - Getting Started - Applying Global Scopes

To assign a global scope to a model, you should override the model's booted method and invoke the model's addGlobalScope method. The addGlobalScope method accepts an instance of your scope as its only argument:


After adding the scope in the example above to the App\Models\User model, a call to the User::all() method will execute the following SQL query:

    select * from `users` where `created_at` < 0021-02-18 00:00:00