issafy/permissions-generator
最新稳定版本:1.0.3
Composer 安装命令:
composer require issafy/permissions-generator
包简介
:permission generation for all your declared routes with corresponding controller action
README 文档
README
This package add some artisan command to help generating permissions for your declared routes.
For the permissions management this package use Laravel-permission by Spatie
Usage
Each of your routes that you want to add permission should have an alias (name) seperated by dot(.) for exemple:
Route::get('/posts/special_action',[App\Http\Controllers\PostController::class, 'specialaction'])->name('posts.specialaction'); Route::get('/posts/another_action',[App\Http\Controllers\PostController::class, 'anotheraction'])->name('posts.anotheraction');
In this example permissions will be generated for the PostController linked to the specialaction and anotheraction
public function __construct()//# { $this->middleware('auth'); $this->middleware(['permission:posts.specialaction'])->only(['specialaction']); $this->middleware(['permission:posts.anotheraction'])->only(['anotheraction']); }//#
Take a look at contributing.md to see a to do list.
Installation
Via Composer
$ composer require mouhamedfd/permissions-generator
Publish configuration
php artisan vendor:publish --tag=permissions-generator.config
The default configuration exclude some keywords and some columns, it's also possible to add some middlewares
return [ 'excluded_keywords'=>[ 'Auth', 'Translation', ], 'have_resource_column'=>false, 'have_description_column'=>false, 'middlewares'=>[ 'auth', ], ];
Usage
Simulation mode
php artisan permission:generate
Database mode
php artisan permission:generate --action=database
Insertion to controllers
php artisan permission:generate --action=controllers
Change log
Please see the changelog for more information on what has changed recently.
Testing PHPUnit
git clone https://github.com/mouhamedfd/permissions-generator.git
composer install
cp vendor/spatie/laravel-permission/config/permission.php vendor/orchestra/testbench-core/laravel/config/permission.php
vendor/bin/testbench cache:clear
vendor/bin/testbench config:clear
composer exec phpunit [or vendor/bin/phpunit]
Contributing
Please see contributing.md for details and a todolist.
Credits
License
MIT. Please see the license file for more information.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-27