New in Laravel 8.70 (Make Request With Model)
source link: https://dev.to/marcosgad/new-in-laravel-870-make-request-with-model-2apl
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Posted on Nov 10
New in Laravel 8.70 (Make Request With Model)
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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK