wovosoft/laravel-permissions
Composer 安装命令:
composer require wovosoft/laravel-permissions
包简介
Roles and Permissions Implementation for https://github.com/spatie/laravel-permission using Laravel and Bootstrap-Vue
关键字:
README 文档
README
Laravel Role & Permissions Front-End Implementation using spatie/laravel-permission
Package description
The package is a Front-End Implementationf of the spatie/laravel-permission package. The spatie/laravel-permission is an awesome package for managing Roles & Permissionf for Laravel applications out of the box. But currently it doesn't have the front-end to easily deploy in your application.
This package comes to solve this problem. The package implements almost every features provided by spatie/laravel-permission.
Features
- Vue Components for each possible features .
- Components are reusable. So, the default layout can be modified according to the needs of your application.
- Currently the front-end uses Bootstrap-Vue. But you can easily change it's layout.
- The front-end vue components are packaged as an npm package. You can use it as a module for you bundlers eg. Webpack,
- Check the main spatie/laravel-permission for more details.
Installation
Install via composer
composer require wovosoft/laravel-permissions
Publish Configuration File
- Publish the configuration file.
php artisan vendor:publish --provider="Wovosoft\LaravelPermissions\ServiceProvider" --tag="config"
- Publish the Vue Components. The Published components will be copied to
resources/laravel-permissions/permissionsfolder. You need to add theMain.vuecomponent to yourapp.js
php artisan vendor:publish --provider="Wovosoft\LaravelPermissions\ServiceProvider" --tag="resources"
- Publish the Migrations
php artisan vendor:publish --provider="Wovosoft\LaravelPermissions\ServiceProvider" --tag="migrations"
- Publish the Seeds
php artisan vendor:publish --provider="Wovosoft\LaravelPermissions\ServiceProvider" --tag="seeds"
Configuration
- In
App\User.phpmodel add theHasRoles.phpTrait.
//other imports goes here use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable { use HasRoles; // other codes goes here }
- Now Run
php artisan migrate
- Go to
config/laravel-permissions.php. Add Default Permissions and Roles.
<?php return [ "route_name_prefix" => "Wovosoft", "route_url_prefix" => "backend", "middleware" => ["web", "auth"], "users_table" => "users", //Default Laravel Generated Name "roles_table" => config("permission.table_names.roles"), //comes from spatie config file. "permissions_table" => config("permission.table_names.permissions"), //comes from spatie config file "default_permissions" => [ [ "name" => "add user", "description" => "Can Add User" ], [ "name" => "edit user", "description" => "Can Edit User" ], [ "name" => "delete user", "description" => "Can Delete User" ] ], "default_roles" => [ [ "name" => "Super Admin", "description" => "Super Admin Manages Everything" ], [ "name" => "User", "description" => "User Role" ], [ "name" => "Customer", "description" => "Customer Role" ] ] ];
- The package adds the routes automatically prefixed by
backend, so your other routes should't be prefixed bybackend. But you can change it inconfig/laravel-permissions.phpconfig file. To check the registered routes, run in your terminal from project the root,
php artisan route:list
- The gates are automatically registered during boot-up by spatie/laravel-permission
Usage
- So, according to
config/laravel-permissions.php(#3) you can perform user abilities as follows:
if(auth()->can('permission')){ echo "Auth user is allowed to perform this operation"; }
if(App\User::find(1)->can('permission')){ echo "Auth user is allowed to perform this operation"; }
$role = Wovosoft\LaravelPermissions\Models\Roles::find(1); if($role->hasAbility('permission')){ echo "The Role with ID 1 is allowed to perform this operation"; }
- Check the main spatie/laravel-permission for more details.
Note
Please keep in mind, the default Role and Permission models provided by spatie/laravel-permission are extended in the package. That's why rather than using
Spatie\Permission\Models\Rolefor Role andSpatie\Permission\Models\Permissionplease useWovosoft\LaravelPermissions\Models\Rolesfor Role andWovosoft\LaravelPermissions\Models\Permissionsfor Permission respectively.
Example Project
Click here to check the demo project https://github.com/wovosoft/laravel-permissions-example
Security
If you discover any security related issues, please email narayanadhikary24@gmail.com or create issue in the Github Repository.
Credits
This package is bootstrapped with the help of wovosoft/crud.
wovosoft/laravel-permissions 适用场景与选型建议
wovosoft/laravel-permissions 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 268 次下载、GitHub Stars 达 9, 最近一次更新时间为 2020 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「User management」 「authorization」 「Authentication」 「roles」 「permissions」 「front-end」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wovosoft/laravel-permissions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wovosoft/laravel-permissions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wovosoft/laravel-permissions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Laravel JWT auth service package
A Silverstripe module to allow you to log into any of your Silverstripe sites from one place.
Task system for APPUI
Standalone replacement for php's native get_browser() function
统计信息
- 总下载量: 268
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-01