I am working on Laravel spark application and the problem is that I can not display the validation errors.
Here is the code. Backend:
$validator = Validator::make($request->all(), [
'email' => 'email|unique:users,email',
'password' => 'min:8'
]);
if ($validator->fails()) {
return redirect('users/add')
->withErrors($validator)
->withInput();
}
Frontend:
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control">
{{json_encode($errors)}}
@foreach ($errors->get('password') as $error)
<p class="checkbox help-block">
<small>{{$error}}</small>
</p>
@endforeach
</div>
The thing is that I am sure that validation rules fail and have checked that. But the error variable is empty...