Files
MeSHard b22d09bd39 init
2025-12-01 11:19:23 +08:00

57 lines
1.0 KiB
PHP

<?php
namespace app\admin\model\yq\base_config;
use think\Model;
class Cargo extends Model
{
// 表名
protected $name = 'cargo_category';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text'
];
public function getStatusList()
{
return ['1' => __('Status 1'),'2' => __('Status 2'),'-1' => __('Status -1')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? '');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
public static function list()
{
$res = self::where('pid',0)->select();
foreach ($res as $k=>&$v){
$v['son'] = self::where('pid',$v['id'])->select();
}
return $res;
}
}