How can I use rules method with formRequest in Laravel Js Validation?

- 1 answer

Ad

This is my Request page: request

{!! \JsValidator::formRequest('App\Http\Requests\Backend\UserRequest', '#my-form') !!}

im trying like this with Laravel JS Validation. But i have some errors like this: errors

I'm using the form like this:

{!! Form::model($user, ['class' => 'form-horizontal form-bordered', 'route' => ['admin.user.update', $user->id], 'method' => 'PATCH', 'id' => 'my-form']) !!}
Ad

Answer

Ad

I solved it like this:

if (\Request::segment(3) == "create")
    return [
        'name'                  => 'required',
        'email'                 => 'required|email|unique:users,email,'.\Request::segment(3),
        'password'              => 'required|min:5|confirmed',
    ];
else
    return [
        'name'                  => 'required',
        'email'                 => 'required|email|unique:users,email,'.\Request::segment(3),
        'password'              => 'min:5|confirmed',
    ];

Maybe it is solves other people's problems. Thanks for interesting my questions...

Ad
source: stackoverflow.com
Ad