Wednesday, March 29, 2017

Laravel, Route required parameter is not validating by Form Request Validation

I am using laravel 5.4

routes/web.php [Route]

Route::get('/email-confirmation/{token}', ['uses' => 'Components\ConfirmationController@sendEmailConfirmation', 'as' => 'web.email.confirmation']);

Components/ConfirmationController.php [Controller]

public function sendEmailConfirmation(EmailConfirmationRequest $request) 
{
dd($request->input('token'));
// ouput is empty
}

// I know that, route required parameter is access by passing in it as second parameter

EmailConfirmationRequest.php [Request]

public function rules()
{
    return ['token' => 'required|max:3'];
}

URL : /email-confirmation/hello - not validating

So, It cannot validated the token parameter in the request.

I am not sure, I am doing something wrong.



via Rafee

Advertisement