Laravel-permission: intelephense says Spatie HasRoles Undefined type

Created on 20 Jun 2020  Â·  3Comments  Â·  Source: spatie/laravel-permission

ภาพ

laravel-use support

Most helpful comment

ภาพ
i use "composer update" and restart vscode ,now i think it's ok (maybe 5555) but now problem is i can't use assignRole()
ภาพ
what should i do??

All 3 comments

It seems either your intelliphense/VSCode is not in sync with composer, or the package is not yet installed therefore the trait is not recognized.

ภาพ
i use "composer update" and restart vscode ,now i think it's ok (maybe 5555) but now problem is i can't use assignRole()
ภาพ
what should i do??

I'm not sure why you're using auth()->user()->assignRole().

Normally calling auth()->user() is used when checking information, not when assigning information.

It would be better practice, and easier to debug, if you first retrieve the object (eg: $user = User::first();) and then do your role assignment (eg: $user->assignRole('something');)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vpratfr picture vpratfr  Â·  4Comments

neoreids picture neoreids  Â·  3Comments

ghost picture ghost  Â·  3Comments

bbdangar picture bbdangar  Â·  4Comments

dylangeorgeharbour picture dylangeorgeharbour  Â·  3Comments