Scope tenant resources to show all models that are part of their tenant
I'm not entirely sure if that title makes sense. Essentially my setup is as follows:
- admin, app & 'partner' panels (the latter is a multi tenant panel)
- A user can have many "licenses", and naturally a partner can belongToMany users
- I want it so a partner can manage the licenses for all users within the partner tenant
So far I've got an eloquent pivot class which has allowed me to register a licenses relationship which using the following allows me to scope the eloquent query on my LicenseResource to show the License models for all users within the partner:
This all works perfectly so far, however when I've added an action to the table, it is not getting the correct related record, if I dd $record in my action; I get the first record when clicking the action on the first 2, and I get the 2nd record when clicking on the third.
I guess my main question is... I'm assuming I'm doing something that's not really an intended use case; I'm not sure if this is a bug or if there's a better way for me to achieve this really. Obvious the multi tenancy aspect expects a "partner" relationship to be on the License model but I can't really achieve this with it being a many-to-many relationship...
0 Replies