定制 phuongdev89/yii2-user-role 二次开发

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

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

phuongdev89/yii2-user-role

最新稳定版本:1.2.0

Composer 安装命令:

composer require phuongdev89/yii2-user-role

包简介

This is simple user role for Yii2

README 文档

README

Install

composer require phuongdev89/yii2-user-role "@dev"

Configuration

in backend/config/main.php or app/config/web.php

[php]
'modules' => [
    'user' => [
        'class' => 'dektrium\user\Module',
        'modelMap' => [
            'User' => 'phuongdev89\role\models\User',//IMPORTANT & REQUIRED, change to your User model if overridden
            'LoginForm' => 'phuongdev89\role\models\forms\LoginForm',//IMPORTANT & REQUIRED, change to your User model if overridden
        ],
    ],
   'role' => [
        'class' => 'phuongdev89\role\Module',
        'controllers' => [ 
            //namespaces of controllers you want to control
            'app\controllers',
            'phuongdev89\role\controllers',
        ],
    ],
],

in console/config/main.php or app/config/console.php

'controllerMap' => [
    ...
    'migrate'  => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationPath' => [
            '@console/migrations',
            '@vendor/dektrium/yii2-user/migrations',
            '@phuongdev89/role/migrations',
        ],
    ],
],

Run migrate

php yii migrate/up

Usage

in model User, if you override it

class User extends \phuongdev89\role\models\User

In every controller you want to check role

class SiteController extends Controller {

    public function behaviors() {
        return [
            'verbs' => [
            ....
            ],
            'role'  => [
                'class'   => RoleFilter::className(),
                'name'    => 'Trang chủ', //NOT REQUIRED, only if you want to translate
                'actions' => [
                    'create', //without translate
                    'index' => 'Danh sách', //with translated, which will display on role _form
                ],
            ],
        ];
    }
}

In everywhere:

use phuongdev89\role\helpers\RoleChecker;
...
//public static function isAuth($controller, $action = '', $role_id = null)
$boolean = RoleChecker::isAuth(SiteController::className(), 'index', Yii::$app->user->identity->getRoleId());

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固