AIParking_Intops_Server/models/AuthItem.php
2020-02-01 16:47:12 +07:00

99 lines
2.6 KiB
PHP

<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "auth_item".
*
* @property string $name
* @property int $type
* @property string $description
* @property string $rule_name
* @property resource $data
* @property int $created_at
* @property int $updated_at
*
* @property AuthItemChild[] $authItemChildren
* @property AuthItemChild[] $authItemChildren0
* @property AuthItem[] $children
* @property AuthItem[] $parents
*/
class AuthItem extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'auth_item';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['name', 'type'], 'required'],
[['type', 'created_at', 'updated_at'], 'integer'],
[['description', 'data'], 'string'],
[['name', 'rule_name'], 'string', 'max' => 64],
[['name'], 'unique'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'name' => 'Name',
'type' => 'Type',
'description' => 'Description',
'rule_name' => 'Rule Name',
'data' => 'Data',
'created_at' => 'Created At',
'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 function roleArray() {
$ls = self::find()->all();
$re = [];
foreach ($ls as $key => $value) {
if (!in_array($value->name, ['hoa_sy', 'kiem_duyet', 'quy_trinh_cu', 'kiem_duyet_kich_ban', 'kiem_duyet_phan_canh', 'kiem_duyet_to_mau', 'kiem_duyet_ve_dong', 'kiem_duyet_sach_xen', 'kiem_duyet_ky_thuat']))
$re[$value->name] = Yii::t("app", $value->description);
}
return $re;
}
}