定制 tadeas-j/permissions 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tadeas-j/permissions

Composer 安装命令:

composer require tadeas-j/permissions

包简介

An easy permissions for Laravel 5.

README 文档

README

An easy Laravel 5 permissions package.

Installation via Composer

require : {
  "tadeas-j/permissions": "dev-master"
}

Next, what you need to do is to run.

composer update

Now, you have successfully installed the package.

Next required step is to add package's service provider to laravel application config, which is located in 'app/config/app.php'.

'Permissions' => 'Permissions\Providers\PermissionsProvider'

And lastly for configuring our permissions and roles we need to publish 'config.php' file to '/config/permissions/config.php'.

php artisan vendor:publish

(Optional) Using package's facade

I highly recommend u to use package's prepared facade, only thing, what you need to do, is to register it in 'app/config/app.php'.

'Permissions' => 'Permissions\Facades\Permissions'

(Important) Configuration

Configuration file should be published to '/config/permissions/config.php'. If you missed it, you can do it easilly with calling this command.

php artisan vendor:publish

At first, you need to put 'role' column to your users table. Default 'config.php' file looks like this.

$aliases = array(
	'manage' => ['create', 'delete', 'edit']
);

$roles = array(
	'admin' => [
		'manage.users',
	]
);

This means, that role 'admin' is allowed to manage.users, 'manage' is alias to 'create', 'delete' and 'edit'. So it is the same like this.

$aliases = array();

$roles = array(
	'admin' => [
		'create.users',
		'delete.users',
		'edit.users',
	]
);

Using package

So let's think about, that we have got one user with role 'admin', 'admin' role is allowed for 'create.users', and the code below is exactly, what we need to do in our creating proccess.

Permissions::can('create.users');

This will get our logged user, his permissions and then it will check them. If we want to check permissions of user with ID 1 for example, we will just easilly do this.

Permissions::can('create.users', User::find(1));

There is also a trait, what you can use.

Permissions\PermissionsTrait

After using this trait in your user model, you will be allowed to do something like this.

Auth::user()->can('create.users');

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-04-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固