New in Laravel 8.70 (Make Request With Model)
Morcos Gad
Posted on November 10, 2021
Let's get started quickly Now, when you run
php artisan make:controller UserController --resource --model=User --requests
it will generate two FormRequest classes: StoreUserRequest
and UpdateUserRequest
, and will replace them in the Controller.
A short version of --requests
flag is -R
, not to mix with -r
for resources.
It is done by reusing the make:request
command and calling it with appropriate class name.
This functionality works only together with --model
flag, otherwise it would be impossible/hard to guess the name for the FormRequest classes.
Also, it works one "layer" above in the Model:
php artisan make:model Project -mcrR
would generate StoreProjectRequest
and UpdateProjectRequest
I hope you enjoy the code.
💖 💪 🙅 🚩
Morcos Gad
Posted on November 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.