init
This commit is contained in:
56
application/admin/model/yq/base_config/Cargo.php
Normal file
56
application/admin/model/yq/base_config/Cargo.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user