I am using Laratrust to add roles to my User
model. I want to add another table to use roles as well. I added modelAs
to the config but Laratrust is confusing the two types. I get the roles from user
with id[3] when querying modelA
with id[3]. All I changed in the config was the user_models array like so:
'user_models' => [
'users' => 'App\User',
'modelAs' => 'App\ModelA'
],
I then added the modelA in role_users
and set user_type
to App\ModelA
|user_id |role_id |user_type |
|-----------|-----------|-----------------|
|3 |6 |App\User |
|3 |7 |App\User |
|3 |8 |App\ModelA |
Is the polymorphic relationship not supposed to know that I am not using the User
model when I use the statement $modelA->roles
?
I believe the problem has to do with caching the roles, because the key used to cache the roles in redis
is laratrust_roles_for_user_3
which would the same for both variations of user_type
. So the Cached values are overwritten? How am I supposed to work around that?
Any help would be appreciated.