zezont4 / laravel-acl
为您的应用添加访问控制层,并提供管理用户、规则和权限的接口
dev-master
2018-08-24 15:20 UTC
Requires
- php: ~5.5|~7.0
- laravelcollective/html: 5.2.*
This package is auto-updated.
Last update: 2024-08-28 05:22:47 UTC
README
要求
PHP >= 5.5.9
Laravel >=5.2
Auto Loaded : [laravelcollective/html package for form & html](https://laravelcollective.com/docs/5.2/html)
感谢
This package is based on @heerasheikh post :
http://heera.it/laravel-5-1-x-acl-middleware#.Vwxunpl95TH
with some fixes , improvment and interface
安装
1. 执行
composer require zezont4/laravel-acl
2. 将服务提供者和别名添加到 /config/app.php 文件。
'providers' => [ \\ Other Providers, Zezont4\ACL\ACLServiceProvider::class, Collective\Html\HtmlServiceProvider::class, ], 'aliases' => [ \\ Other Aliases, 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, ],
3. 将 acl 中间件添加到 **app\Http\Kernel.php **
protected $routeMiddleware = [ \\ Other routeMiddleware, 'acl' => \Zezont4\ACL\Http\Middleware\CheckPermission::class, ];
4. 在 app\User.php 中使用 UserTrait
class User extends Authenticatable { use \Zezont4\ACL\Models\UserTrait; \\ the rest of the class }
5. 发布资源和配置文件
php artisan vendor:publish --provider="Zezont4\ACL\ACLServiceProvider" --tag="config" --tag="assets"
6. 在您的路由中使用它
Route::get('/users', [ 'middleware' => 'acl:manage_user', 'as' => 'users.all', 'uses' => 'UserController@index' ]);
Blade 指令
@hasRole('manager') .... @endhasRole
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。