I have this blogController, the create function is as follows.
public function create() { if($this->reqLogin()) return $this->reqLogin(); return View::make('blogs.create'); }
In BaseController, I have this function that checks if a user is registered.
public function reqLogin(){ if(!Auth::check()){ Session::flash('message', 'You need to login'); return Redirect::to("login"); } }
This code works fine, but this is not what I need, I want my create function to be next.
public function create() { $this->reqLogin(); return View::make('blogs.create'); }
Can I do it?
Also, can I set authentication rules, as in Yii , at the top of the controller.
source share