skip to Main Content

How can I get around this warning in PhpStorm?

Property 'id' not found in IlluminateContractsAuthAuthenticatable|null

for

auth()->user()->id

Note, that this question relates to PhpStorm not Laravel. The id exists and Laravel doesn’t show the warning. The IDE does.

2

Answers


  1. Maybe you can try with Auth::user()->id and you can show this warning, you should to do a dd(auth()->user()) and you can show that are happening. Maybe your user it´s not logged and for this Laravel show this warning

    Login or Signup to reply.
  2. Phpstorm does not know about the object. You can add something like this to your user model:

    /**
     * @property int $id
     */
    
    class User ....
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search