entrust icon indicating copy to clipboard operation
entrust copied to clipboard

Default roles & permissions

Open ghost opened this issue 7 years ago • 3 comments

How should I create default roles and permissions ?

The ones that should be by default in my app (admin role would suit me for now).

Where should I put this code so it creates automatically (somehow?)

$admin               = new Role();
$admin->name         = 'admin';
$admin->display_name = 'User Administrator';
$admin->description  = 'User is allowed to manage everything';
$admin->save();

P.S. I'm a quite a beginner in PHP and Laravel.

ghost avatar Jan 24 '18 22:01 ghost

You should create a seeder for this. You can check the seeds documentation here https://laravel.com/docs/5.5/seeding.

Usually you run your seeders after running your migrations.

CamiloManrique avatar Jan 26 '18 14:01 CamiloManrique

I think this is out of the scope of this package. It's really up to you how to create those roles and permissions and you should ask on stackoverflow or similiar. As mentioned @CamiloManrique the correct and best way would be a seeder for this.

psychonetic avatar Feb 11 '18 10:02 psychonetic

https://github.com/thomasfw/RolesAndPermissionsSeeder

davidvexel avatar Feb 13 '18 02:02 davidvexel