Using session to store the selected preference to view data for all groups or just a specific group is a good solution. When a user visits a page, check which preference is stored in session and return the filtered data to the front end.
Laravel inertia scope for client selection
Hey, I wonder what the best practice for this use case would be: I have an application where the user is asigned to one or many groups, now my idea is to have a drop down in the front end where he can select for which group he wants to see data (models are linked via polymorphic relationship to the group) or if he wants to see data for all groups in the application.
My first idea was to store the information inside the session and apply global scopes to all my models based on the data stored in the session and if selected "all" just do an early return there.
But that feels kinda hacky. Do you guys have a better idea on how it could be implemented?
Thanks :)
Please or to participate in this conversation.