Hi

One thing that is buggeing me is that php tools does not recognise that the Laravel methods Auth::user() and auth()->user() returns a User model object and there for one get errors
/warnings like this:

    rabol this is valid because laravel model uses magic method.

    <?php
    
    if (null !== $user = Auth::user()) {
        assert($user instanceof User);
        // to something with $user
    }

      From what I see, the Auth::user() method is declared as

       /** @method static \Illuminate\Contracts\Auth\Authenticatable|null user()

      Would it help to add a more specific type annotation to .phpstorm.meta.php or _idehelper.php?

        I'm happy to do any annotation, I just think that PHP Tools should be abele to do it on it's own.

        I would like to only use VSCode... but phpstorm offers some features e.g. like this :)

          My phpstorm doesn't :)

          Maybe there's some additional config/meta file?

            stripe_id, name is table columns.

            Could be the Laravel Idea plugin that do the trick

            and the helper files that the plugin is generating is also available to PHP Tools, so it should be possible

              I see, The plugin puts the generated helpers into /vendor/ folder (which is, at least, unexpected).

              Thank you for pointing me in the right direction.

              Still, I don't see where they found out auth()->user() returns User model tho :) I'll keep looking, we'll be implementing similar support for Laravel for VSCode anyways.

              edit: it seems it's specified in laravel-idea.xml settings file or there's some other magic

                Do you know, is there any way we can find out that auth()->user() returns our App\Models\User class?

                Just releasing pre-release which handles _ide_helper and _laravel_idea; which helps in most cases, but still this one is missing.

                cc @ging-dev

                  We may handle completion after Illuminate\Contracts\Auth\Authenticatable (that's what all these methods are returning), assuming it's a user model, and find the class extending Illuminate\Foundation\Auth\User.

                    ging-dev More complicated, they are defined in config/auth.php:

                    <?php
                        'providers' => [
                            'users' => [
                                'driver' => 'eloquent',
                                'model' => App\Models\User::class,
                            ],
                            // other providers
                        ],

                    So each Auth::guard('name of provider')->user() will return a different model.

                      ging-dev nice ...

                      So the generated .phpstorm.meta (and maybe ide-helper, _laravel_idea) should probably already define the stubs with the correct type? But I don't see it there.

                        Write a Reply...