Laravel Artisan command for generating Request validation Class

Related Articles

God make:request The command can be used to create new application validation classes. You can enter the class name to create the class. The name will be used as the class and file name.

Follow the example below to create a Request class in Laravel.

php artisan make:request ProductPostRequest

New app/Http/Requests/ProductPostRequest.php The file will be created and will contain content similar to the following file:


namespace AppHttpRequests;

use IlluminateFoundationHttpFormRequest;

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 does not exist, but if it does it will throw an error as Request already exists!

System staff

The editorial team at Tutsplanet is a dedicated team for writing various tutorials on topics such as programming, technology and operating systems.



Please enter your comment!
Please enter your name here

Popular Articles