📜  如何检查用户是否在 laravel 中的非中间件控制器中登录 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:46.990000             🧑  作者: Mango

代码示例1
How to check if a user is logged in, in a non middleware controller
  in laravel?
  
  auth Auth::guard
    
    if (Auth::guard('api')->check()){ //will return true if logged in
      //do this 
    }
  else //if the user is not logged in
  {
    //do this
  }