我正在开发一个项目,我被指派使用laravel开发Web应用程序。我正在使用laravel 5.2.x,当路由不在登录,注销等的auth组中时,每个工作正常。
登录后,我定义了一个只能由经过身份验证的用户访问的组,例如admin。
routes.php文件
/ Authentication Routes...
$this->get('/login', [ 'as' => 'auth.loginForm', 'uses' => 'Auth\AuthController@showLoginForm']);
$this->get('/', [ 'as' => 'auth.loginRoot', 'uses' => 'Auth\AuthController@showLoginForm']);
$this->post('/login',[ 'as' => 'auth.login', 'uses' => 'Auth\AuthController@login']);
$this->get('/logout', [ 'as' => 'auth.logout', 'uses' => 'Auth\AuthController@logout']);
// Password Reset Routes...
$this->get('/password/reset/{token?}', [ 'as' => 'auth.resetForm', 'uses' => 'Auth\PasswordController@showResetForm']);
$this->post('/password/email', [ 'as' => 'auth.passwdEmail', 'uses' => 'Auth\PasswordController@sendResetLinkEmail']);
$this->post('/password/reset', [ 'as' => 'auth.reset', 'uses' => 'Auth\PasswordController@reset']);
Route::group(['middleware' => ['auth']], function(){
....
$this->get('/register', [ 'as' => 'auth.register', 'uses' => 'Auth\AuthController@showRegistrationForm']);
$this->post('/register', [ 'as' => 'auth.create', 'uses' => 'Auth\AuthController@register']);
$this->get('/register/verify/{confirmationCode}', ['as' => 'auth.confirmation', 'uses' => 'Auth\AuthController@confirm']);
$this->get('/dashboard', [ 'as' => 'auth.dashboard', 'uses' => 'Auth\AuthController@index']);
....
});
现在,当我在控制器上执行dd()
时,注册页面上的验证工作正常,但错误消息未显示在刀片中。我在登录时做的验证,这些工作正常。我不明白实际问题是什么。
更新 会话闪存消息也不会显示,有时会显示,但大多数时候这些错误或会话闪存消息都不会显示。
register.blade.php
@extends('layouts.layout') @section('content')
<div class="panel-content register_cont">
<div class="tabs_cont ">
<ul class="tabs_btn nav nav-tabs">
<li class="active"><a href="javascript:;" data-tab="tab1">New Account</a></li>
</ul>
<div class="tab-content">
<div class="tab1 active tab-pane">
<div class="col-md-10">
<div class="row">
{!! Form::open(array('url' => 'register', 'autocomplete' => 'off')) !!}
<div class="col-md-8 col-md-offset-2">
<br/>
<h3><strong>New</strong> User Account</h3>
<hr/>
<div class="form-group required {{ $errors->has('email') ? ' has-error' : '' }}">
{{ Form::label('email', 'Email', array('class' => 'control-label')) }}
{!! Form::text('email', old('email'), array('placeholder' => 'Email Address', 'class' => 'form-control')) !!}
@if ($errors->has('email'))
<div class="error-msg">{{ $errors->first('email') }}</div>
@else
<div class="error-msg">Email is required</div>
@endif
</div>
<div class="form-group row">
<div class="col-md-4 required {{ $errors->has('title') ? ' has-error' : '' }}">
{!! HTML::decode(Form::label('title', 'Title <span class="red-astrisk">*</span>', array('class' => 'control-label'))) !!}
{{ Form::select('title', ['' => 'Title', 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.', 'Miss.' => 'Miss.', 'Dr.' => 'Dr.'], old('title'), array('class' => 'form-control')) }}
@if ($errors->has('title'))
<div class="error-msg">{{ $errors->first('title') }}</div>
@else
<div class="error-msg">Title is required</div>
@endif
</div>
<div class="col-md-8 required {{ $errors->has('first_name') ? ' has-error' : '' }}">
{!! HTML::decode(Form::label('first_name', 'First Name <span class="red-astrisk">*</span>', array('class' => 'control-label'))) !!}
{!! Form::text('first_name', old('first_name'), array('placeholder' => 'First Name', 'class' => 'form-control')) !!}
@if ($errors->has('first_name'))
<div class="error-msg">{{ $errors->first('first_name') }}</div>
@else
<div class="error-msg">First name is required</div>
@endif
</div>
</div>
<div class="form-group required {{ $errors->has('last_name') ? ' has-error' : '' }}">
{!! HTML::decode(Form::label('last_name', 'Last Name <span class="red-astrisk">*</span>', array('class' => 'control-label'))) !!}
{!! Form::text('last_name', old('last_name'), array('placeholder' => 'Last Name', 'class' => 'form-control')) !!}
@if ($errors->has('last_name'))
<div class="error-msg">{{ $errors->first('last_name') }}</div>
@else
<div class="error-msg">Last name is required</div>
@endif
</div>
<hr/>
<div class="form-group btn_cont">
<button type="submit" class="btn btn-theme">Create</button>
</div>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
请帮帮我。