我正在使用Laravel注册的默认类。问题: 提交表单时,我知道有错误,因为没有将用户添加到数据库中。但是当我使用
{{dd($errors)}}
结果是
ViewErrorBag {#226 ▼
#bags: []
}
我的验证规则是
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
以及注册表
<form method="POST" action="{{ route('register') }}" class="form-signin">
@csrf
<img src="img/branding.svg">
<h2 class="form-signin-heading">{{__('Registreer')}}</h2>
<label for="email" class="sr-only">E-mailadres</label>
<input type="email" id="email" name="email" class="form-control" placeholder="E-mailadres" required autofocus>
<label for="name" class="sr-only">Gebruikersnaam</label>
<input type="text" id="name" name="name" class="form-control" placeholder="Gebruikersnaam" required>
<label for="password" class="sr-only">Wachtwoord</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Wachtwoord" required>
<label for="password_confirmation" class="sr-only">Wachtwoord</label>
<input type="password" id="password_confirmation" name="password_confirmation" class="form-control" placeholder="Wachtwoord (herhaal)" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">{{ __('Registreren') }}</button>
{{dd($errors)}}
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</form>
一切都很好,但是我不知道为什么Laravel没有列出错误
答案 0 :(得分:0)
我找到了解决方法。
Laravel对会话目录(存储/框架/会话/)没有写访问权 将其更改为适当的设置后,我可以看到错误消息
chmod 777 -Rv storage/
(R =递归) (v =详细)