我有這個blogsController,創建函數如下。重定向在laravel沒有return語句
public function create() {
if($this->reqLogin()) return $this->reqLogin();
return View::make('blogs.create');
}
在BaseController,我有這個功能,如果用戶登錄,檢查。
public function reqLogin(){
if(!Auth::check()){
Session::flash('message', 'You need to login');
return Redirect::to("login");
}
}
此代碼工作正常,但它是不是有什麼需要,我想我的創建功能如下。
public function create() {
$this->reqLogin();
return View::make('blogs.create');
}
我可以嗎?
除此之外,我可以設置authantication規則,就像我們在Yii框架中那樣,在控制器的頂部。
Yii不等於laravel。爲什麼標籤Yii。 – crafter 2014-08-31 13:11:26
我想要一個已經在兩者上工作過的人的回答。 – anwerj 2014-09-01 05:21:03