我正在开发 Laravel spark 应用程序,问题是我无法显示验证错误。
这是代码。后端:
$validator = Validator::make($request->all(), [
'email' => 'email|unique:users,email',
'password' => 'min:8'
]);
if ($validator->fails()) {
return redirect('users/add')
->withErrors($validator)
->withInput();
}
前端:
<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>
问题是我确信验证规则失败并且已经检查过了。但是错误变量为空...