entrust
entrust copied to clipboard
Default roles & permissions
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.
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.
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.
https://github.com/thomasfw/RolesAndPermissionsSeeder