Create observer on table role_has_permissions #2050
Replies: 1 comment
-
Here is what i ended up with, it has nothing to do with an observer on the role_has_permissions and here is why (i don't know if missed something). First of all i have to sync my role's permission and this results in a mass update (either going through the So instead i had to add code wherever i update the role's permission (fortunately only at one place), and after syncing the permissions i retrieve all the users for that role (little cool thing is that there is a Another solution would have been to update the 'updated_at' attribute on the role after doing the sync and putting the rest of my code in a RoleObserver but since i only have it in one place i prefer to keep it there so there is no ambiguity. This is a bit frustrating but i'll look at it again in one or two weeks in case i missed something :) |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
My use case is that when i update a role's permissions, under some conditions i may need to get all the users that already have that role assigned and make an api call to another service with that users list.
I'm starting to work on implementing an oberver on the role_has_permissions pivot table and i will share my code here if it works out as expected, but any advice is welcome as i feel this might be tricky to implement.
Have a nice day,
Sean.
Beta Was this translation helpful? Give feedback.
All reactions