aliwael/permissions
最新稳定版本:v1.0
Composer 安装命令:
composer require aliwael/permissions
包简介
Laravel package for user permissions management.
关键字:
README 文档
README
Manage user permissions and roles in Laravel.
Features
- Manage permissions and assign them to users.
- Manage roles and assign them to users and permissions.
- Middleware to check for permissions or roles.
- Traits to add permissions and roles to the User model.
- Ready-to-use migrations for all required tables.
Installation
- Add the package to your project:
composer require aliwael/permissions
- Publish migration and helper files automatically:
php artisan vendor:publish --tag=permissions-assets
- Run the migrations:
php artisan migrate
- Add Traits to your User model:
use Permissions\Traits\HasPermissions; use Permissions\Traits\HasRoles; class User extends Authenticatable { use HasPermissions, HasRoles; // ... }
Usage
Assign Permission or Role
$user->givePermission('edit-post'); $user->assignRole('admin');
Check Permission or Role
$user->hasPermission('edit-post'); $user->hasRole('admin'); $user->hasPermissionViaRole('edit-post');
Middleware in Routes
Route::get('/admin', function () { // ... })->middleware('role:admin'); Route::post('/post', function () { // ... })->middleware('permission:edit-post');
Tables
- permissions: Permissions.
- roles: Roles.
- user_permission: User-permission pivot table.
- role_user: User-role pivot table.
- permission_role: Role-permission pivot table.
Contributions
To contribute or report an issue, please open an Issue or Pull Request at: https://github.com/aliwael/permissions
This package was developed to make managing permissions and roles in Laravel projects easy.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-07