6

New in Laravel 8.70 (Make Request With Model)

 2 years ago
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.
neoserver,ios ssh client
Marcos Gad

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
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

would generate StoreProjectRequest and UpdateProjectRequest

I hope you enjoy the code.

Source :-
https://github.com/laravel/framework/pull/39120


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK