SparkRoles, based on Caffeinated Shinobi, brings a simple and light-weight role-based permissions system to Laravel Spark's Team and User models through the following ACL structure:
- Every user can have zero or more roles.
- Every user can have zero or more permissions.
- Every team can have zero or more roles.
- Every team can have zero or more permissions.
- Roles and permissions can be shared between users and teams.
- Optionally, users and teams with a certain role (e.g.
developer
) are added to the Spark developer's array.
Permissions are then inherited to the team/user through the team/user's assigned roles.
This package is a replacement for Caffeinated Shinobi when building a project based on Laravel/Spark
.
You will find user friendly documentation in the ZiNETHQ SparkRoles Wiki BEING UPDATED
-
Install the package through Composer.
composer require zinethq/spark-roles:dev-master
-
Add the service provider to your project's
config/app.php
file.ZiNETHQ\SparkRoles\SparkRolesServiceProvider::class,
-
Publish the configuration, models, and migrations into your project.
php artisan vendor:publish --provider="ZiNETHQ\SparkRoles\SparkRolesServiceProvider"
-
Migrate your database.
php artisan migrate
-
Add the
CanUseRoles
trait to yourTeam
and/orUser
models, for example:app\Team.php
<?php namespace App; use Laravel\Spark\Team as SparkTeam; use ZiNETHQ\SparkRoles\Traits\CanHaveRoles; class Team extends SparkTeam { use CanHaveRoles; ... }
app\User.php
<?php namespace App; use Laravel\Spark\User as SparkUser; use ZiNETHQ\SparkRoles\Traits\CanHaveRoles; class User extends SparkUser { use CanHaveRoles; ... }
-
Optional: If you'd like to dynamically assign the Spark developer array based on team/user roles then open
app\Http\kernel.php
and add the following to theweb
middleware group:\ZiNETHQ\SparkRoles\Middleware\AddDevelopers::class,
This middleware can be controlled (enabled/disabled and choose the role slug that identifies developers) in the package's configuration file.
-
Start using roles for your Spark teams and users!
Fork, edit, pull request. You know the drill.
If you'd like to contribute consider helping with one of the following:
-
Add Travis CI integration -
Add PHPUnit support - Add meaningful unit tests
- Add a Kiosk based frontend for defining roles and permissions, similar to Watchtower for Shinobi
Caffeinated Shinobi is an awesome tool for Laravel that adds Role Based Access Control (RBAC) to your user model. There is also a cool UI for Shinobi called Watchtower. Go take a look!