I have created function in laravel helper class to check Authentication in app/lib/Auth.php
class Auto extends \BaseController {
public static function logged() {
if(Auth::check()) {
return true;
} else {
$message = array('type'=>'error','message'=>'You must be logged in to view this page!');
return Redirect::to('login')->with('notification',$message);
}
}
}
In my controller
class DashboardController extends \BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
Auto::logged();
return View::make('dashboard.index');
}
I expect it redirect to login route if not logged, but it load dashboard.index
view with message 'You must be logged in to view this page!'.
How can I redirect to login route with this message?