admin管理员组

文章数量:1123233

Latest Laravel with PHP 8.3 and intelephense plugin for autocomplete in VSC. If I using a method from a Model class Trait like createToken() in a User Model that using tokens, but the autocomplete is not working well. It is working inside the Model class, but when I use the model outside like in a Controller, it is not. The method itself is working, but no hint during the coding.

The beginning of the Model class:

. . .
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasFactory, Notifiable, HasApiTokens;
. . .

Then I try to use in controller the HasApiTokens method:

. . .
$user = User::where('email', $email)->first();
. . .
$user->tokens()->delete();
. . .
$user->token = $user->createToken('auth_token')->plainTextToken;

No codehint over the tokens() or createToken() or any Trait stuffz. The method itself is working well, so no program error but no hint during the coding.

The codes above is only part of the code, so now worry about what missing! It is only show the lines that is important in the problem.

本文标签: laravelVSC PHP Intelephense not see class trait in ControllerStack Overflow