Blog


Laravel - Apply Global Scopes only on certain routes with Middleware

Article image

Laravel include a Query Scopes system. It allow you to add to one or all (depend the type of scope you use) queries a scope with constraints. Query Scopes has 2 types of Scopes :

  • Global Scopes : It allow you to add constraints to all queries for a given model.
  • Local Scopes : It allow you to define common sets of query constraints that you may easily re-use throughout your application.

In...