52 lines
1.9 KiB
PHP
52 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use DateTimeInterface;
|
|
use support\think\Model;
|
|
|
|
class Base extends Model
|
|
{
|
|
protected function getOptions(): array{
|
|
return [
|
|
'connection' => 'mysql',
|
|
'createTime' => 'created_at',
|
|
'updateTime' => 'updated_at',
|
|
'deleteTime' => 'deleted_at',
|
|
'autoWriteTimestamp' => 'int',
|
|
//'dateFormat' => false
|
|
// query 自定义数据库查询对象类名(默认为空)
|
|
// type 需要自动转换的字段及类型(数组,默认为空)
|
|
// autoValidate 是否自动验证(开启后会自动进行数据验证)
|
|
// validate 对应验证类名或验证规则(字符串或数组,autoValidate参数开启后有效)
|
|
// strict 是否严格区分字段大小写(默认为true)
|
|
// disuse 废弃字段(数组,默认为空)
|
|
// readonly 只读字段(数组,默认为空)
|
|
// hidden 输出隐藏字段(数组,默认为空)
|
|
// visible 输出显示字段(数组,默认为空)
|
|
// append 输出追加字段(数组,默认为空)
|
|
// mapping 字段映射(数组,默认为空)
|
|
// autoRelation 自动with关联(数组,默认为空)
|
|
// insert 自动新增写入(数组,默认为空)
|
|
// update 自动更新写入(数组,默认为空)
|
|
// dateFormat 时间输出格式化设置
|
|
];
|
|
}
|
|
/**
|
|
* 格式化日期
|
|
*
|
|
* @param DateTimeInterface $date
|
|
* @return string
|
|
*/
|
|
protected function serializeDate(DateTimeInterface $date)
|
|
{
|
|
return $date->format('Y-m-d H:i:s');
|
|
}
|
|
function getStatusList(){
|
|
return [
|
|
'0' => '隐藏',
|
|
'1' => '正常',
|
|
];
|
|
}
|
|
}
|