cxfoot/models/auth/RoleUser.php
2023-10-27 14:25:12 +08:00

68 lines
1.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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;
}
}
}