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