I have this path:
Route::get('forgotten-password/confirm/{code}'
And I want after validation failing to return to this exact path, but it redirects me one step more to
Route::get('forgotten-password')
I use Request classes, so it automatically makes the validations and returns me back. If it was custom in the controller, I could make:
if ($validator->fails())
{
return redirect('forgotten-password/confirm/{code}');
}
Any suggestions how to make it work?
Try this way
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'title' => 'required|max:255',
'name' => 'required',
]);
if ($validator->fails()) {
return redirect('post/create')
->withErrors($validator)
->withInput();
}
}