This will make a Form Request class for you - to remove validation and authorization from your controller https://laravel.com/docs/5.6/validation#creating-form-requests
When do we use make:request in laravel?
I've searched about this long time and all I see everywhere is basic usage of request() or Request $request...
When i search on laravel documentation pages about php artisan make:request something, I looked up for using ajax and only thing on docs is you make new request and for response you get json.
When I look on other websites for using ajax with laravel they make:requests but why when I can use controller and check is request ajax or not, and then do what is needed to?
It's used for form validation, so you don't have to do it in the controller. https://laravel.com/docs/5.6/validation#form-request-validation
It works the same whether it's a regular form or ajax request. If you send the right headers with the ajax request, laravel will automatically return json. You don't need to check...it's automatic. You just need to set a "accept: application/json" header and laravel will see that and return json.
You should also be sending "X-Requested-With: XMLHttpRequest" headers
Please or to participate in this conversation.