📜  laravel 控制器构造函数 auth user null - PHP 代码示例

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

代码示例1
class BaseController extends Controller
{
    public $user_info;
  
    public function __construct(){
      $this->middleware(function ($request, $next) {
        $this->user_info=Auth::user(); // returns user
        return $next($request);
      });
    }
}