doc88/flux-entity-permission
Composer 安装命令:
composer require doc88/flux-entity-permission
包简介
Library for implementing entities access control in Laravel applications.
README 文档
README
Library for implementing entities access control in Laravel applications.
Requirements
- Laravel >= 6.0
Installation
- Run the command below at the project root to add the package to the Laravel application:
composer require doc88/flux-entity-permission
- In the providers list in the config/app.php file add:
'providers' => [ ... Doc88\FluxEntityPermission\FluxEntityPermissionServiceProvider::class, ]
- Run the command below at the root of your project to publish the new provider:
php artisan vendor:publish
- Run migrations
php artisan migrate
- In your User Model add the following lines:
use Doc88\FluxEntityPermission\Traits\HasEntityPermissions; class User { use HasEntityPermissions; }
Usage
Doc88\FluxEntityPermission\EntityPermission Class
Class used to List, Register, Verify and Revoke permissions to entities.
- List Entities from a User’s Permissions
// Entities which the user has access to EntityPermission::list($user); // Specifying which entity you want to list EntityPermission::list($user, 'App\Company'); /** * Return: array */
- List Entities IDs from a User’s Permissions
// Ids of entities which the user has access to EntityPermission::idList($user, 'App\Company'); /** * Return: array */
- Checks a User’s Permission to an Entity
// The entity you want to access $company = Company::find(1); // Checking if the user has access to the entity EntityPermission::has($user, $company); /** * Return: true or false */
- Records permission to an Entity
// The entity you want to access $company = Company::find(1); // Grants permission to the entity for the User EntityPermission::register($user, $company); /** * Return: true or false */
- Revokes permission to a Entity
// The entity you want to access $company = Company::find(1); // Revokes permission to the Entity EntityPermission::revoke($user, $company); /** * Return: true or false */
Using the User Model
It is possible to List, Register, Verify and Revoke permissions to entities using the User class.
- List User Permissions
$user = User::find(1); // Entities which the user has access to $user->listEntityAccess(); // Specifying which entity you want to list $user->listEntityAccess('App\Company'); /** * Return: array */
- Checks User Permission to an Entity
$user = User::find(1); // The entity you want to access $company = Company::find(1); // Checking if the user has access to the entity $user->hasEntityAccess($company); /** * Return: true or false */
- Records permission to an Entity
$user = User::find(1); // The entity you want to access $company = Company::find(1); // Grants permission to the entity for the User $user->registerEntityAccess($company); /** * Return: true or false */
- Revokes permission to an Entity
$user = User::find(1); // The entity you want to access $company = Company::find(1); // Revokes permission to the entity $user->revokeEntityAccess($company); /** * Return: true or false */
doc88/flux-entity-permission 适用场景与选型建议
doc88/flux-entity-permission 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.44k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 07 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 doc88/flux-entity-permission 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 doc88/flux-entity-permission 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-06