update phân quyền chi tiết

This commit is contained in:
2020-11-02 14:35:22 +07:00
parent c4bb81e55c
commit e4a665dd2e
29 changed files with 1188 additions and 343 deletions

View File

@@ -47,12 +47,12 @@ class AuthItem extends \yii\db\ActiveRecord {
*/
public function attributeLabels() {
return [
'name' => 'Name',
'name' => 'Tên quyền',
'type' => 'Type',
'description' => 'Description',
'description' => 'Ghi chú',
'rule_name' => 'Rule Name',
'data' => 'Data',
'created_at' => 'Created At',
'created_at' => 'Ngày tạo',
'updated_at' => 'Updated At',
];
}
@@ -85,8 +85,17 @@ class AuthItem extends \yii\db\ActiveRecord {
return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable('auth_item_child', ['child' => 'name']);
}
public static $roleArray = [
"department" => "Phòng ban",
"staff" => "Nhân viên",
"area" => "Khu vực",
"device" => "Thiết bị",
"schedule" => "Kiểm soát truy cập",
"logs" => "Báo cáo"
];
public static function roleArray() {
$ls = self::find()->all();
$ls = self::find()->andWhere(['type' => 1])->all();
$re = [];
foreach ($ls as $key => $value) {
$re[$value->name] = Yii::t("app", $value->description);
@@ -94,4 +103,13 @@ class AuthItem extends \yii\db\ActiveRecord {
return $re;
}
public function getChildList() {
$ls = AuthItemChild::find()->andWhere(['parent' => $this->name])->all();
$re = [];
foreach ($ls as $key => $value) {
$re[] = $value->child;
}
return $re;
}
}