MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.2k stars 258 forks source link

How to give delete/Edit action only for admin user type #415

Open sayadkm opened 2 years ago

sayadkm commented 2 years ago

I am having users list table with action for Delete and Edit, but I want to restrict the action only for Admin users, how can I add the action column only for admin users and for non admins don't need to show the column

thyseus commented 2 years ago

I suggest to read:

https://laravel.com/docs/9.x/authorization

or, when having more complex situation, to use a extension like

https://github.com/JosephSilber/bouncer

which integrates nicely with livewire-datatables !

sayadkm commented 2 years ago

I suggest to read:

https://laravel.com/docs/9.x/authorization

or, when having more complex situation, to use a extension like

https://github.com/JosephSilber/bouncer

which integrates nicely with livewire-datatables !

But I didn't see any proper section regarding restricting the action column (Delete/Edit) for a perticular user type in datatables in the above mentioned docs

thyseus commented 2 years ago

You can publish the views with

php artisan vendor:publish --provider="Mediconesystems\LivewireDatatables\LivewireDatatablesServiceProvider"

and adjust the views to your custom situation. Ensure to also restrict the actions in your Controllers.