Skip to content

Request Validate Generator

The Request Validate Generator will create a new Validate Class for the provided Resource with a basic boilerplate code. If you want to create a new ProfileValidate file, for the Customer Module, you can run the following command:

bash
php artisan modular:make-validate Customer Profile

Or if you are using Laravel Sail, run:

bash
sail artisan modular:make-validate Customer Profile

And a new file will be created at modules/Customer/Http/Requests/ProfileValidate.php.

Validation Rules

Add the validation rules for the Profile resource as needed:

php
<?php

namespace Modules\Customer\Http\Requests;

use Modular\Modular\Http\Requests\Request;

class ProfileValidate extends Request
{
    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255',
            'is_active' => 'required|boolean',
        ];
    }
}

By the default this validator will be used by the modules/Customer/Http/Controllers/ProfileController.php for the store and update methods.

Validation Messages

The responses and validation errors, will be automatically handled by your Vue Pages, and if needed, you can translate the messages as usual in a Laravel Application, and it will be fully integrated with the Vue Components Side.