64], [['name'], 'unique'], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'name' => 'Tên quyền', 'type' => 'Type', 'description' => 'Ghi chú', 'rule_name' => 'Rule Name', 'data' => 'Data', 'created_at' => 'Ngày tạo', 'updated_at' => 'Updated At', ]; } /** * @return \yii\db\ActiveQuery */ public function getAuthItemChildren() { return $this->hasMany(AuthItemChild::className(), ['parent' => 'name']); } /** * @return \yii\db\ActiveQuery */ public function getAuthItemChildren0() { return $this->hasMany(AuthItemChild::className(), ['child' => 'name']); } /** * @return \yii\db\ActiveQuery */ public function getChildren() { return $this->hasMany(AuthItem::className(), ['name' => 'child'])->viaTable('auth_item_child', ['parent' => 'name']); } /** * @return \yii\db\ActiveQuery */ public function getParents() { 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()->andWhere(['type' => 1])->all(); $re = []; foreach ($ls as $key => $value) { $re[$value->name] = $value->description ? $value->description : $value->name; } return $re; } public function getChildList() { $ls = AuthItemChild::find()->andWhere(['parent' => $this->name])->all(); $re = []; foreach ($ls as $key => $value) { $re[] = $value->child; } return $re; } }