68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
||
|
||
namespace app\models\auth;
|
||
|
||
use Yii;
|
||
|
||
/**
|
||
* This is the model class for table "{{%auth_role_user}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property int $role_id 用户角色ID
|
||
* @property int $user_id 用户ID
|
||
* @property int $created_at 添加时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
* @property int $deleted_at 删除时间
|
||
*/
|
||
class RoleUser extends \yii\db\ActiveRecord
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%auth_role_user}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['cx_mch_id', 'role_id', 'user_id'], 'required'],
|
||
[['cx_mch_id', 'role_id', 'user_id', 'created_at', 'is_delete', 'deleted_at'], 'integer'],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'role_id' => '用户角色ID',
|
||
'user_id' => '用户ID',
|
||
'created_at' => '添加时间',
|
||
'is_delete' => '是否删除:0=否,1=是',
|
||
'deleted_at' => '删除时间',
|
||
];
|
||
}
|
||
|
||
public function beforeSave($insert) {
|
||
if(parent::beforeSave($insert)){
|
||
if($this->isNewRecord){
|
||
$this->created_at = time();
|
||
}
|
||
if($this->is_delete == 1)
|
||
$this->deleted_at = time();
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
}
|