I'm building a web app in Laravel 5.2. I'm relatively new to Laravel, and want to follow best practices. I have a table called Roles that have several named user roles (i.e.: admin, editor, etc). I want the admin to be able to edit the permissions for these roles and create new ones. What would be the best way to store the permissions?
- Use an integer field with each bit representing one permission? (I think this would quickly get out of hand)
- Use a pivot table and a many-many connection to permissions?
- Use a string field and just serialize the chosen privileges?
New privileges are likely to be added in the future, and my goal is to be able to easily determine if a user has a certain role or not. I.e.: $user->roles->hasAdmin() or something simirar.
via Moha