I have a controller with several methods and I need to add a specific authorization check. If authorization failed then redirect login page. So for this reason i have created one private function and this function call in constructor.
class AdminController extends Controller
{
public function __construct()
{
$this->middleware('web');
$this->isLogin();
}
private function isLogin()
{
if (!empty(Auth::user())) {
echo "Hello";
} else {
echo "Fasd";
return Redirect::to('/login');
}
}
}
If auth is not found is does not redirect to login. What i write extra code for this?