Recommend this page to a friend! |
Classes of Thiago Przyczynski | Simple Laravel Role Management | README.md | Download |
|
DownloadSimpleRolePackage that adds a simple role based authentication system to any Laravel project. Installing and using
Run the migration that will add role column to your users table, as:
>Add roles using Enrollable Trait
This trait will add setRole($role) method to the User model and you will be able to update users role with it:
>Add roles using Laravel standard attributes If you don't want to use the Enrollable trait you can add 'role' column to your fillable attributes on User model:
Define the different types of role that you will be working and use the middleware to be handle on your routes as shown above: web.php
A route can require more than one role, to do that you just need to add comma separated roles.
I'm aware of other packages that can do the same with more power allowing multiple roles and other stuff, but this package contains the simplest way of doing that and will allow small projects to run a simple role based with a small footprint. |