2016-12-01 62 views
1

laravel 5重定向到前一頁登錄後。laravel 5重定向到後簽收前一頁

當我手動打一個網址,如果它不是在其redrecting登錄到登錄頁面,但登錄後應該重定向到輸入的網址,但在我的情況下,它將進入主頁。

代碼:

public function index() 
    { 

      // Is the user logged in? 
     if (Auth::check()) 
     { 
      return Redirect::route('dashboard'); 
     } 

     // Show the page 
     return View('auth.login'); 
    } 


public function getSignin() 
    { 

      // Is the user logged in? 
     if (Auth::check()) 
     { 
      return Redirect::route('dashboard'); 
     } 

     // Show the page 
     return View('auth.login'); 
    } 
+0

或者我應該改變中間件? – user6527

+1

[Laravel可能重複登錄後重定向回原始目的地](http://stackoverflow.com/questions/15389833/laravel-redirect-back-to-original-destination-after-login) – jannej

回答

0

您可以在使用的情況下,如果redirect()->back()在用戶登錄

+0

redirect() - > back ();不會工作,因爲以前的網址將是登錄頁面,如果它的登錄頁面已經登錄,它將重定向到主頁... – user6527

+0

你可以在這裏找到你的答案:[link](http://stackoverflow.com/questions/15389833/laravel-redirect-back-to-original-destination-after-login?noredirect = 1&lq = 1) –

+0

沒有使用middelware,我們可以這樣做嗎? – user6527