Download the PHP package zine-admin/permission without Composer

On this page you can find all versions of the php package zine-admin/permission. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package permission

用户角色权限包

写在前面

验证方式:本包的权限验证思路有别于其它权限包,权限格式以 操作:资源父级/资源下级 操作资源格式,下级权限默认是继承上线资源的权限,例如:

上面的意思表示角色 editor 拥有dashboard资源下的的所有权限,但是不能更新用户操作update:dashboard/users 和 对角色资源的操作*:dashboard/roles 但是可以拥有查看角色的权限view:dashboard/roles, 如以下代码:

管理添加系统中的所有权限资源 本包没有提供permissions表以存储所有可分配的权限表,而是以注册的形式,假如我们开发一个会员模块,可以在某个ServiceProvider中注册,如:

权限注册后,可以通过以下方式把系统中所有地方注册过的资源显示出来,然后可以授权给某个角色或用户。 通过这种方法,你可以很方便的为用户角色进行授权。

perm view:

一旦安装你就可以这样使用:

您可以使用Laravel的默认功能测试用户是否具有权限:

Installation

This package can be used in Laravel 5.4 or higher.

You can install the package via composer:

执行安装脚本

安装脚本执行以下过程 复制数据库迁移文件和配制文件, 执行迁移命令

1、 复制数据库迁移文件 (migrations) 、配制文件(config) 和 数据填充文件(seeds):

2、 执行迁移脚本将数据库表迁移至你的数据库中

运行迁移命令将会创建三张表:roles role_has_permissions user_has_roles 三张表的名称可以在config/permission.php配制文件中修改

3、 重新加载文件

4、 填充数据seeds

默认添加角色 admin user

5、在用户模型文件 (app/user.php) 添加权限特性 (use HasRoles) 和 hasSuperAdmin方法

User.php

Usage

First, add the ZineAdmin\Permission\Traits\HasRoles trait to your User model(s):

创建角色

Using model create

Using artisan command

注册权限

本包没有permissions表,系统中的权限可以在boot中注册。

注册的权限资源会自动生成tree对象,结构如下:

获得权限资源一维数组的结构

为角色授予权限或禁止权限

用户分配角色

角色可以分配给任何用户

First, add the ZineAdmin\Permission\Traits\HasRoles trait to your User model(s):

角色可以分配给任何用户:

角色也可以同步:

从用户身上移除角色,返回成功删除的数量

角色和权限检查

检查角色

确定用户是否有指定角色

or

您还可以确定用户是否具有所有给定的角色列表:

检查权限

确定角色是否具有某种权限:

确定用户是否具有给定的全部权限

Blade指令

Blade and Roles

测试一个特定的角色:

is the same as

确定是否有列表中任一角色

确定是否有列表中所有角色

Blade and Permissions

使用Laravel的本地@can指令来检查用户是否具有某个权限。

or

middleware

Using a middleware

已注册如下中间件:

你可以使用中间件规则来保护你的路由:

或者,您可以用|(管道)字符分隔多个角色或权限:

您可以通过在构造函数中设置所需的中间件来类似地保护您的控制器

controller

利用控制器方法上的注释来检查权限和角色

首先在控制器添加HasPermissionsForController Trait

First, add the ZineAdmin\Permission\Traits\HasPermissionsForController trait to your Controller Controller:

Catching role and permission failures

If you want to override the default 403 response, you can catch the UnauthorizedException using your app's exception handler:

cache

缓存角色和权限数据以加速性能。

当您使用提供的方法来处理角色和权限时,缓存会自动为您重置:

手动清除所有缓存

role-tree

角色表支持无限树结构,更详细请访问Documentation

添加一个子节点:

祖先和后代

根据ID查询祖先和后代

转化为树形结构

转化为扁平树

获取指定节点的子树

删除节点:

重要!该节点的任何后代也将被删除!

不能使用查询删除

这将破坏树结构

你可以检查树是否被破坏(即有一些结构错误):

修复树


All versions of permission with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/support Version 5.*
kalnoy/nestedset Version 4.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zine-admin/permission contains the following files

Loading the files please wait ....