2015-01-24 7 views
0

사용자가 로그인해야하는 페이지에 액세스하려고 할 때 로그인 페이지로 보내고 싶지만 메시지도 보내고 싶습니다.로그인하지 않은 상태에서 Laravel 리디렉션

Route::filter('auth', function() 
{ 
    if (Auth::guest()) 
    { 
     if (Request::ajax()) 
     { 
      return Response::make('Unauthorized', 401); 
     } 
     else 
     { 
      return Redirect::guest('start')->withErrors('Please login to access that page.'); 
     } 
    } 
}); 

을하지만 내 메시지 가방이 비어 :

나는 있습니다.

어떻게하면됩니까?

+1

가게를하고 당신이 완료 후 sessionvariable에서 제거 그것 – ITroubs

+0

고마워, 플래시 내가 내가 원하는 것입니다. – imperium2335

+0

어떻게 접속하고 있습니까? withVariable을 사용하여 이미 세션에 저장 ... – Jazerix

답변

0

나는 당신을 도울 수 있다고 생각합니다.

return Redirect::route('Your route here)->with('message', 'Your message here'); 

그리고 당신의보기에서 메시지를 표시합니다 : 컨트롤러에서

당신은 할 수있는 세션 변수에

@if (Session::has('message')) 
     <div id="message">{{ Session::get('message') }}</div> 
@endif 
관련 문제