Domanda

What is the exact reason to use route filters in Laravel. Filter logic can be added to the controller and that way all the logic will be in the controller, not spread across multiple files.

È stato utile?

Soluzione

Typically with the MVC pattern it is preferred that your Controller files are kept pretty lean. That means, they should only handle passing data to and from the Model and View files. Filters applied to routes allow you to apply specific logic, for example validating someone has the necessary roles to view the page, without fattening your controller.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top