osaris-uk/access 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

osaris-uk/access

最新稳定版本:2.0

Composer 安装命令:

composer require osaris-uk/access

包简介

Role & Permission based access control package for Laravel

README 文档

README

Usage

For Laravel 5.5 - 5.7 use v1.3.2

After running the migrations, you can start using the package by adding the AccessTrait to your user model.

use OsarisUk\Access\AccessTrait;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, AccessTrait;
}

By default all user accounts will be created with the 'user' role, this can be configured in the access config.

You can publish the config file with:

php artisan vendor:publish --provider="OsarisUk\Access\AccessServiceProvider" --tag="config"

This package will read your default user model from Laravel's auth config auth.providers.users.model.

Middleware

This package ships with AccessMiddleware. This allows you to protect your routes allowing access to users with specific roles:

Route::group(['middleware' => ['access:admin|moderator']], function () {
    //
});

Route::group(['middleware' => ['access:user']], function () {
    //
});

You can also allow access to users with specific permissions:

Route::group(['middleware' => ['access:user,create posts']], function () {
    //
});

Route::group(['middleware' => ['access:user,remove posts']], function () {
    //
});

Route::group(['middleware' => ['access:,edit posts']], function () {
    //
});

Blade Directives

This package integrates with the default Laravel Blade directive @can, this allows you to show content based on a users assigned permission including permissions they have been assigned through a role:

@can('edit posts')
    <a href="#">Edit Post</a>
@endcan

There is also a @role Blade directive included in this package, this allows you to show content based on a users assigned role:

@role('moderator')
    <a href="#">Remove Post</a>
@endrole

Available Methods

giveRoles(...$roles)
withdrawRoles(...$roles)
updateRoles(...$roles)
givePermissionTo(...$permissions)
withdrawPermissionTo(...$permissions)
updatePermissions(...$permissions)
hasRole(...$roles)
hasPermissionTo($permission)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固