Are you talking about Laravel Nova?
Using scope / policy / indexQuery for limiting what a user can see&do?
Hi all,
W have an application where people manage projects. One project can have multiple users, one user can have multiple projects, so we have a many to many for that.
I would like a select in the topbar: "Select your project". A lot of resources available for that user fall under a project, so when user has selected project ID 1, I want to show all resources where BelongsTo project_id = 1.
I'm a bit hesitant what to do, should I use a policy for this? Or a scope, or something else? How would you guys set this up?
And could someone point me to the right way how to add a select-field next to the search bar in the header if there's a proper way to do it please? I can hack it myself but hopefully there's a better way I haven't found before.
I think I understand now, you want a select bar to scope everything to that project? Easiest way I can think of is following:
- on dashboard add all projects that user has relationship to
- let user pick specific project and store that in session
- use that session data to scope every
indexQueryto selected project - change template to show selected project
What you can also try is:
- change template to show selecting of projects
- on change set selected project to session
- use that session data to scope every
indexQueryto selected project
Seems doable.
Please or to participate in this conversation.