z1haze / laravel-acl
A simple to use ACL for Laravel 5.3
Installs: 171
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 3
Forks: 0
Open Issues: 2
pkg:composer/z1haze/laravel-acl
Requires
- php: >=7.0
- illuminate/support: 5.3.*|5.4.*
Requires (Dev)
- doctrine/dbal: ^2.5
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~5.0
README
Laravel-ACL is a Laravel 5.3|5.4 level based access control package with explicit negating capabilities that makes for easy management for hierarchical permissions systems.
Table of Contents
Requirements
- This package requires PHP 7+
Getting Started
Require the package via composer.
$ composer require z1haze/laravel-acl
or
{
"require": {
"z1haze/laravel-acl": "0.4.*"
}
}
Register the service provider in config/app.php.
'providers' => [ ... z1haze\Acl\Providers\AclServiceProvider::class, ... ],
Publish and configure the configuration file before migrating.
php artisan vendor:publish --provider="z1haze\Acl\Providers\AclServiceProvider"
Migrate the database
php artisan migrate
This package is designed for the models to be extended with your own models, which can be setup in the config.
Also ensure that make the newly added
level_idfield fillable on your user model.
Register the middleware in app/Http/Kernel.php.
protected $routeMiddleware = [ ... 'laravel-acl' => \z1haze\Acl\Middleware\HasPermission::class ... ],
Add the following HasAcl trait to your user model.
use \z1haze\Acl\Traits\HasAcl class User extends Model implements AuthenticatableContract, CanResetPasswordContract { use Authenticatable, CanResetPassword, HasAcl; }
Documentation
For more detailed information, read the Wiki.
Roadmap
Current TODO's
- Add directives for blade or find a way to extend the existing laravel ones
- Add middlware support for route resources
Changelog
February 6, 2017
- Updated
getAllPermissionsto return only permissions inherited and assigned even if the level/user has the master permission. Having the master permission itself returned infers a user has access to every permission anyway.
February 3, 2017
- Added
assignLevelfor the permission model - Added
clearLevelfor the permission model - Added
addUser,addUsersfor the permission model - Added
removeUser,removeUsersfor the permission model
February 1, 2017
- Added
syncPermissions(array)for both users and levels - Added
getNegatedPermissions()for the user model - Added
isHigherThan(),isLowerThan(), andisEqualTo()for comparing ranks for users and levels - Added exceptions for permissions/levels that return no results