Search code examples
phplaraveldesign-patternssolid-principlesdesign-principles

Authorizing in controller constructor vs form request


When should I authorize in controller constructor using authorizeResource like here and when should I use Authorizing Form Requests like here?


Solution

  • You authorize a controller when you want to authorize more than one action. The authorizeResource covers multiple actions, while the form request is for the current request only.

    You could use form request authorization when you would like to authorize only the store and update actions for example, as for those more often a FormRequest is used.