N
N
NikolayAlb2017-05-09 17:31:06
Laravel
NikolayAlb, 2017-05-09 17:31:06

Laravel, validator doesn't see bound parameters?

I can't find what the problem is, a simple get request:

Route::post('delete-member/{user}', '[email protected]')
                ->name('member.remove');

In the controller I'm trying to validate:
$this->validate($request,[
        'user' => 'required|exists:users,name'
    ]);

But it returns an error that the user field is required. $request->user receives the correct username. What could be the problem?
Validation only works if the route is written without /{user}.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
someart, 2017-05-09
@NikolayAlb

Your validate() validates the request's payload. Your user must be an argument to the controller action.
Read/google "routes named parameters"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question