lipeng93 / authority
A privilege control program for Laravel
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/lipeng93/authority
This package is auto-updated.
Last update: 2025-12-14 18:04:20 UTC
README
- PHP >= 7.0.0
- Laravel >= 5.5.0
Installation
This package requires PHP 7+ and Laravel 5.5
First, install laravel 5.5, and make sure that the database connection settings are correct.
composer require lipeng93/authority
Then run these commands to publish assets and config:
php artisan vendor:publish --tag=lipeng93-authority
After run command you can find config file in config/authority.php, in this file you can change the install directory,db connection or table names.
Set your login user model and primary key , then this model must to extends Lipeng93\Authority\UserModel
At last run php artisan migrate to finish install.
php artisan migrate
-
create role
Authority::role()->add('admin','超级管理员') -
create permission
Authority::permission()->add('角色权限列表','role.permissions.index'); -
role sync permission
public function syncPermissions(RoleModel $role) { return Authority::role()->syncPermissions($role,[1,2,3,4,5,6,7,8,9,10,11,12]); } -
sync user role
public function syncUserRoles(User $user,RoleModel $role) { return $user->role()->sync([$role->id]); } -
verify user authority
public function verifyUserAuthority(User $user) { return $user->verifyAuthority('route_name'); } -
users all permission
$user->permission();