Php 表单验证LAVEL会话数据

Php 表单验证LAVEL会话数据,php,laravel,laravel-4,cartalyst-sentry,Php,Laravel,Laravel 4,Cartalyst Sentry,我正在尝试使用laravel4使用sentry进行表单验证。当我使用下面显示的代码时,会捕获错误,但会话数据似乎不会发送回视图,以在登录时通知用户问题。我做错什么了吗?我一直在我的应用程序中这样在视图之间传递会话数据 这是我的控制器操作: public function handleLogin() { try{ $credentials = array( 'email' => Input::get('email'),

我正在尝试使用
laravel4
使用
sentry
进行
表单验证。当我使用下面显示的代码时,会捕获错误,但
会话
数据似乎不会发送回
视图
,以在登录时通知用户问题。我做错什么了吗?我一直在我的应用程序中这样在视图之间传递
会话
数据

这是我的
控制器操作

public function handleLogin() { 
    try{
        $credentials = array(
            'email'    => Input::get('email'),
            'password' => Input::get('password'),
        );

        $user = Sentry::authenticate($credentials, false);
        if($user){
            if($user->hasAccess('admin')){//Admin Base Controller - Dashboard Display welcome
                return Redirect::action('BookController@index')->with('message', $user->first_name . " " . $user->last_name);
            }else{//User Base Controller - Dashboard Display 
                return Redirect::to('user/dashboard/')->with('message', 'Welcome User');
            }
        }   
    //Error with logging in redirect to login page and display error
    }catch(Cartalyst\Sentry\Users\LoginRequiredException $e){
        return View::make('home.login')->with('message', 'Login field is required.');
    }catch(Cartalyst\Sentry\Users\PasswordRequiredException $e){
        return View::make('home.login')->with('message', 'Password field is required. ');
    }catch(Cartalyst\Sentry\Users\WrongPasswordException $e){
        return View::make('home.login')->with('message', 'Wrong password, try again.');
    }catch (Cartalyst\Sentry\Users\UserNotFoundException $e){
        return View::make('home.login')->with('message', 'User was not found.');
    }catch (Cartalyst\Sentry\Users\UserNotActivatedException $e){
        return View::make('home.login')->with('message', 'User is not activated.');
    }
}
这是我的
视图

@if(Session::has('message'))
    <div class="alert alert-success alert-dissmissible" role="alert">
        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span>
        <span class="sr-only">Close</span>
        </button>
        <strong>Goodbye: </strong>{{ Session::get('message') }}
    </div>
@endif

@if(Session::has('success'))
    <div class="alert alert-success alert-dissmissible" role="alert">
        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span>
        <span class="sr-only">Close</span>
        </button>
        <strong>Success: </strong>{{ Session::get('success') }}
    </div>
@endif


    <div class="page-header">
        <h1>Login</h1>
    </div>  
    <!-- Login Form -->
    <form action="{{action('HomeController@handleLogin')}}" method="post">
        <div class="form-group">
            <label for="email">Email</label>
            <input type="text" class="form-control" name="email"/>
        </div>
        <div class="form-group">
            <label for="password">Password</label>
            <input type="password" class="form-control" name="password"/>
        </div>
        <input type="submit" value="Login" class="btn btn-primary"/>
    </form>
@stop
@if(会话::has('message'))
&时代;
接近
再见:{{Session::get('message')}
@恩迪夫
@if(会话::has('success'))
&时代;
接近
成功:{{Session::get('Success')}
@恩迪夫
登录
电子邮件
密码
@停止
A
视图::make()->with('foo','Error')
$foo
作为变量传递,而不是设置会话变量

也许你可以试试:

@if(isset($message))
    <div class="alert alert-success alert-dissmissible" role="alert">
        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span>
        <span class="sr-only">Close</span>
        </button>
        <strong>Goodbye: </strong>{{ $message }}
    </div>
@endif
@if(isset($message))
&时代;
接近
再见:{{$message}
@恩迪夫