Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

icode15's avatar

Dynamic save permissions on application deploying

Hi, i want to generate permissions on application deploying by using Seeder

To do that: My Controllers have a property "requirePermission" it's a array that contains methods i want to access with permissions

I.e in DepartmentContoller i have $this->requirePermission=['index','create','store','show','update','detatch','edit','destroy'];

On deploy i want to browse them and save all permissions in table like

DepartmentContoller .create DepartmentContoller .store .... Any idea?

0 likes
3 replies
Robstar's avatar
Robstar
Best Answer
Level 50

For most of my apps I have set of built in permissions that I store in a config file at config/permissions.php.

During deployment and/or initial seeding I run a small article command I created i.e. php artisan permissions:refresh.

This command basically creates the permission in the database if it doesn't already exist.

icode15's avatar

Not bad i'am using your method thanks

Please or to participate in this conversation.