Model Validation

❗️

Develop branch

This functionality exists only in the develop branch

You can add custom validation method in your model.

For example:

use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use LaravelAdminPanel\Contracts\ModelValidator;
use Validator;

class User extends Model implements ModelValidator

...

    public function validate(Request $request)
    {
        $rules = [
            'email' => [
                'required',
                Rule::unique('users')->ignore($this->id)
            ]
        ];

        return Validator::make($request->all(), $rules);
    }

More information about laravel validation you can click on the link https://laravel.com/docs/validation