I\'m new to Laravel (only experienced Laravel 5, so no legacy hang up here)
I\'d like to know how to extend the core Request class. In addition to how to extend it,
I was able to add custom request object using FormRequest
in Laravel 5.5 as follows.
First, just create FormRequest
:
php artisan make:request MyRequest
Then just make it look like this:
You can then use MyRequest
as drop-in replacement in any function that takes Request
as parameter:
public function get(MyRequest $request)
{
}
I do realize that FormRequest
s are actually meant to be used for a different purpose, but whatever works.
Documentation on FormRequest
: https://laravel.com/docs/5.0/validation#form-request-validation