2016-09-24 102 views
0

我正在使用laravel 5.3。 假設我在(url.com)/posts/5在laravel應用程序。現在我想登錄。登錄後我想重定向回這個URL。我只想編輯Auth Controller中的這些行。 protected $redirectTo = '/';這裏說,在評論Where to redirect users after login/registration.重定向到上一個url或返回()登錄/註冊後在Laravel 5.3

class LoginController extends Controller 
{ 
    use AuthenticatesUsers; 

    /** 
    * Where to redirect users after login/registration. 
    * 
    * @var string 
    */ 
    protected $redirectTo = '/'; 


    public function __construct() 
    { 
     $this->middleware('guest', ['except' => 'logout']); 
    } 
} 

我怎麼能這樣做? 注:我正在使用laravel內置身份驗證。

回答

1

嘗試這種在RedirectsUsers.php

編輯:我是新的Laravel但在測試驗證後,它通過 默認重定向回。

<?php 

namespace Illuminate\Foundation\Auth; 

trait RedirectsUsers 
{ 
    /** 
    * Get the post register/login redirect path. 
    * 
    * @return string 
    */ 
    public function redirectPath() 
    { 
    // return property_exists($this, 'redirectTo') ? $this->redirectTo : '/'; 
    return redirect()->back(); 
    } 
} 
相關問題