42 lines
773 B
PHP
42 lines
773 B
PHP
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
use think\Model;
|
|
use think\model\concern\SoftDelete;
|
|
|
|
/**
|
|
* 有关时间的模型
|
|
* Class TimeModel
|
|
* @package app\common\model
|
|
*/
|
|
class TimeModel extends Model
|
|
{
|
|
|
|
public array $statusText = [
|
|
1 => '启用',
|
|
-1 => '禁用',
|
|
0 => '未启用',
|
|
];
|
|
/**
|
|
* 软删除
|
|
*/
|
|
use SoftDelete;
|
|
|
|
protected function getOptions(): array
|
|
{
|
|
return [
|
|
'autoWriteTimestamp' => true,
|
|
'createTime' => 'create_time',
|
|
'updateTime' => 'update_time',
|
|
'deleteTime' => false,
|
|
];
|
|
}
|
|
|
|
public function getStatusTextAttr($value): string
|
|
{
|
|
return $this->statusText[$value] ?? '未知状态';
|
|
}
|
|
|
|
|
|
} |