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

74 lines
1.7 KiB
PHP

<?php
namespace app\models\file;
use Yii;
use app\models\Model;
/**
* This is the model class for table "{{%file_group}}".
*
* @property int $id ID
* @property int $cx_mch_id 平台商户ID
* @property int $user_id 用户ID
* @property string $name 名称
* @property int $is_default 是否默认
* @property int $is_delete 是否删除
* @property int $created_at 添加时间
*/
class FileGroup extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%file_group}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['cx_mch_id', 'user_id', 'is_default', 'is_delete', 'created_at'], 'integer'],
[['name'], 'required'],
[['name'], 'string', 'max' => 512],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'cx_mch_id' => '平台商户ID',
'user_id' => '用户ID',
'name' => '名称',
'is_default' => '是否默认',
'is_delete' => '是否删除',
'created_at' => '添加时间',
];
}
public function beforeSave($insert) {
if(parent::beforeSave($insert)){
if($this->isNewRecord){
$this->created_at = time();
}
$this->htmlTagFilter();
return true;
} else {
return false;
}
}
public function htmlTagFilter()
{
$this->name = Model::htmlTagFilter($this->name);
}
}