thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.77k stars 2.67k forks source link

Adding Json to allowed users to only see his own records from dropdown menus #3536

Closed Benoit1980 closed 5 years ago

Benoit1980 commented 6 years ago

It would be excellent to be able to limit the users to see only their own records via the json fileds near each fields.

ie: A user creates a business from the business page and projects from the project page. Upon creating a task, the user needs to be able to only see his business name and project name from the dropdown menu in the task page.

This is something that happens a lot in CRUDs.

nunomsh commented 6 years ago

In did a good feature, but you can create your own lists in the controller, and pass then to the view. I have several projects that require the same logic, what I've done is create the select list,checkind the user role or id, and create the list where user_id==the user logged. And when admin is logged you can simple show all the records if user_role==1

Benoit1980 commented 6 years ago

Yes, this is what I did, I created models, controllers and so on. The part I did not like is that I cannot preselect the drop-down menu, the user has to physically click on them, did you find a way around this, please? The other problem is when you want to show data of a second dropdown based on the choice of the first one. I can only work this one out with Ajax, I did not find any features in Voyager that helps with this. The reason I was asking about the above is that I have been using for years a little php app maker called Appgini and it has all these features packed in(seeing your own records or population of second dropdown menu based on the choices of the first one), the reason I moved to Laravel is that I needed more options like sending emails, S3 and redis and others.

nunomsh commented 6 years ago

For the menus in my case all I want is to show the possible options for each user, I don't need to click just need to show the possible options, it's up to use decide if they use or not. As for the second, ajax is the solution, since the values are related to the previous one. ie: brands and models; To select the model you need the brand... What about datatables? It has some nice plugins, or you can create some simple relations. https://datatables.net/forums/discussion/15851/dependent-dropdown-example https://github.com/cyberhobo/ColumnFilterWidgets

Benoit1980 commented 6 years ago

Sorry I am not sure I understand what you mean, do you need help with your dropdown menus? Also the links you are posted do not work. Thanks

fletch3555 commented 6 years ago

URLs fixed

Benoit1980 commented 6 years ago

For data table I think this plugin is great: https://www.datatables.net/ under MIT license. Using Jquery.

Or if you prefer Vue: https://onewaytech.github.io/vue2-datatable/doc/#/en/preparation

emptynick commented 5 years ago

This is something you can do with Scopes

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.