DEV Community

Morcos Gad
Morcos Gad

Posted on

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 mode Exit 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 mode Exit fullscreen mode

would generate StoreProjectRequest and UpdateProjectRequest

I hope you enjoy the code.

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

Top comments (0)