cxhxy/app/common/model/TemplateCode.php
2023-11-21 15:14:59 +08:00

79 lines
1.9 KiB
PHP

<?php
namespace app\common\model;
/**
* 模板代码模型
*/
class TemplateCode extends BaseModel
{
// 定义表名
protected $name = 'template_code';
// 定义主键
protected $pk = 'template_code_id';
// 追加字段
protected $append = [];
/**
* 平台类型
*/
public function getMpAttr($value)
{
$status = [10 => '微信', 20 => '支付宝'];
return ['text' => $status[$value], 'value' => $value];
}
/**
* 关联模板市场表
*/
public function template()
{
return $this->belongsTo('app\\common\\model\\Template','app_type','app_type');
}
/**
* 获取列表
*/
public function getList()
{
// 执行查询
return $this->order('template_code_id','desc')
->paginate(['list_rows'=>15,'query' => request()->param()]);
}
/**
* 获取详情
*/
public static function detail($template_code_id)
{
$filter = [
'template_code_id' => $template_code_id
];
return self::where($filter)->find();
}
/**
* 获取最新模板
*/
public static function getNew(string $app_type,$mp = '10')
{
$filter = [
'app_type' => $app_type,
'mp' => $mp
];
return self::where($filter)
->order('template_code_id','desc')
->find();
}
/**
* 获取指定版本模板详情
*/
public static function getCode(string $app_type,$user_version,$mp = '10')
{
$filter = [
'app_type' => $app_type,
'user_version' => $user_version,
'mp' => $mp
];
return self::where($filter)
->order('template_code_id','desc')
->find();
}
}