1
This commit is contained in:
42
app/common/model/TimeModel.php
Normal file
42
app/common/model/TimeModel.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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] ?? '未知状态';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user