The install went smoothly but I don't know where should I create the roles:
$subscriber = new Role();
$subscriber->name = 'Subscriber';
$subscriber->save();
I've seen some tutorials where they add it in something like
Route::get('/start') but I don't want developers to have to go through this page every time. I would like something automated like migrations.
In fact my question is rather general and not only related to Entrust.
Do I have to create a bash script that I add to my composer or is there anything in Laravel already thought for that ? May I add this kind of code to a migration ?
It really depends on your structure.
You can put it in your usercontroller or other controller that makes sense for smaller projects.
You can also create a new class and decorate the controller . There are plenty of ways to do this.
Hey @manshu
At first I added it as a migration, I didn't like the idea to have it in the controller.
In the end, I discovered that since version 5.11 Laravel includes powerful ACL features so Entrust was not needed in my case.
The ACL in the "out-of-the-box" laravel does not save things to the database, everything is defined in code via a Policy and using the Gate class.
Entrust gives you a bit more control because you can just change the database (no code change/release required).
$subscriber = new Role();
$subscriber->name = 'Subscriber';
$subscriber->save();
goes into a migration in the up() method or you can just manually create these records in the database. Then there is a role_user table where you can match up roles to users. This is course-grained like admin, manager, user, etc. so big chunks suitable for maybe a group route
If you want even more granular stuff (like an extra level), then you can layer in the permissions part. These may be on each of your controller functions but this is not necessary