Authorization and validation are two different things.
Edit:
If you have authorization properly implemented, a non authorized user will never make it to that form to fill out.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I do love laravel but as the training videos age and the Laravel versions change the techniques the instructors use to accomplish tasks tends to be very different over time.
I'm reading the docs regarding policies (Ver.9) and they recommending applying a policy in the controller using something like:
public function create(ArtworkRequest $request, User $user){
$this->authorize('create', Artwork::class);
direct()->route('artworks.index');
}
And then I'm watching a Laravel Cookbook video & reading the docs about using the validaton() method inside a FormRequest class.
Which is better and why? I actually dislike the options and find "well it depends" statements in the training to be increasingly unhelpful and frustrating.
And while I'm on the topic of FormRequests, does anybody think the -R flag for creating FormRequests while creating a controller is a bit redundant?
php artisan make:controller TestController -R
Why?
The convenient -R flag creates two form request files:
That means you are duplicating your logic in two separate files for essentially the same task: saving a record. Of course the rules for the model will be the same for both inserting and updating, so why does Laravel think having two separate FormRequest files is the way to go?
Perhaps I'm missing something.
Where to put the authorization is one of those things that is mostly personal choice. I don't think it has any reason to be in a form request and would never put it there. For me form requests are for validation. But I rarely use the authorize method either as that allows validation to run. Instead I put them on the route directly as middleware, to stop the request early.
In regards to two form requests. The reason is that they are not the in a lot of cases. Imagine working with posts. The name of the post is unique. But when you update you want to ignore the post itself. Same is true for all unique fields. Or maybe a profile picture is required when creating a profile, but not updating it. That said, people often add extra logic to just use 1 form request for both. So if you prefer that just delete 1 or create one seperately
Please or to participate in this conversation.