2016-04-05 26 views
1
class DashboardController extends BaseController { 

protected $layout = "layouts.dashboard"; 
public function __construct(){ 

//$this->beforeFilter('csrf', array('on'=>'post')); 
$this->beforeFilter('auth', array('only'=>array('getIndex'))); 

} 
public function getIndex(){ 
    $this->layout->content= View::make('dashboard.index'); 
} 



} 

上面給出的代碼是我dashboardController。當我登錄並重定向到儀表板時可以。用戶在儀表板中時,表示用戶已通過身份驗證。現在在url欄中,我點擊登錄的網址。在我的情況下,它是重定向到儀表板,如果用戶在Laravel 4.2的loggedIn

http://localhost:8000/users/login 

現在它重定向,即使在用戶登錄登錄。現在,當我想知道我們如何可以重定向到authomatically儀表板如果用戶登錄。 我對laravel 4.2來說是新的。我希望你能指導我。林失去了在本節

+0

我會建議直接跳到laravel 5並看看中間件它只是哇https://laravel.com/docs/5.2/middleware –

+0

但是,如果您已經創建了路由和視圖文件過濾器只是將它應用於您的登錄就是了! –

回答

1

你可以試試把這個變成你的getIndex()功能:

if(Session::has('login_parameters')) return Redirect::to('foo/dashboard'); 

我在Laravel 3使用此代碼,希望它工作在laravel 4.2爲好。

+0

謝謝mishad050 –

+0

很高興我能幫助你。如果它適合你,你會考慮標記這個答案是否正確? – mishad050

相關問題