-
I like many others use spatie/laravel-permission library and am struggling being abel to access the roles in the UserTable.
anyone have suggestions on how to access the roles in the user table table? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Here is how I accomplished it, not sure if there is a better way
|
Beta Was this translation helpful? Give feedback.
-
I knew it was causing extra queries, but because Spatie uses morphMany i don't think it is supported. here is my Component
|
Beta Was this translation helpful? Give feedback.
-
So morphMany isn't supported in terms of automatically detecting and joining the relation properly. It is however supported if you use the builder() approach. I'll try to give an example in the next day or two, but the docs do explain using builder() as far as I can recall You can then use format or label with the related data loaded in I use that approach for loading in related teams/roles/permissions (albeit not with Spatie but with another package, but still morphMany) |
Beta Was this translation helpful? Give feedback.
-
I also have tried to add a function to the model User::class
but am unsure how to return the function as a column in component and couldn't find it in the docs |
Beta Was this translation helpful? Give feedback.
Here is how I accomplished it, not sure if there is a better way