The make:request
command can be used to generate new request validation request classes. You can input the name of the class to generate the class. The name will be used as the name of the class and the file.
Follow the example below to generate a Request class in Laravel.
php artisan make:request ProductPostRequest
A new app/Http/Requests/ProductPostRequest.php
file would be created and contain contents similar to the following:
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class ProductPostRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ // ]; } }
The above command will try to create a new file if it’s not existing, but if it’s existing it will throw an error like Request already exists!
Search Words
create request in laravel via command line
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply