문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top