简体   繁体   中英

Laravel 5.1 Entrust - Setting up first roles/permissions

I installed entrust on my laravel 5.1. I'm wondering what's the best way to create your first roles?

I see some people creating them with routes but this doesn't seem like a clean way to me. Should I just seed my first roles directly into my database or is there a better way?

In my opinion, this is up to personal preference. As you mentioned already, using a database seeder is a perfectly reasonable solution.

If you really want to contain and separate the code that initializes the roles/permissions, or anything else you need in your application, you can also opt to create a custom Artisan command within Laravel that does the initial setup tasks you need to do. With this method, you can separate your initial production set-up and you can still utilize your database seeders without having to modify them for testing purposes.

Resources:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM