0

我正在使用 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 没有列出错误

4

1 回答 1

0

我找到了解决方案。

Laravel 没有对会话目录 (storage/framework/sessions/) 的写入权限,在我将其更改为正确的设置后,我能够看到错误消息

chmod 777 -Rv storage/

(R = 递归) (v = 详细)

于 2018-09-21T12:03:31.060 回答