Can't call Auth::user() on controller's constructor

后端 未结 3 1448
情书的邮戳
情书的邮戳 2020-11-28 13:49

I\'m trying to check if the user has permission to a certain model. Up until now (with Laravel 5.2), I added this code at the constructor:

public function __         


        
3条回答
  •  生来不讨喜
    2020-11-28 14:27

    Because you're attempting to access the instance before the middleware even fires. You can use request()->user() instead.

提交回复
热议问题