You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/common/model/user/Identity.php

72 lines
1.6 KiB

11 months ago
<?php
namespace app\common\model\user;
use app\common\enum\user\IdentityEnum;
use cores\BaseModel;
11 months ago
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
11 months ago
class Identity extends BaseModel
{
// 定义表名
protected $name = 'user_identity_price';
// 定义主键
protected $pk = 'identity_id';
11 months ago
11 months ago
/**
* 追加字段
* @var array
*/
protected $append = [
'type_text', //身份文字描述
];
/**
* 获取器:身份文字描述
* @param $value
* @param $data
* @return string
*/
public function getTypeTextAttr($value, $data): string
{
// 身份
$result = IdentityEnum::data();
if (!empty($result[$data['type']]['name'])) {
return $result[$data['type']]['name'];
}
return '未知';
}
11 months ago
/**
* @notes:获取全部记录
* @param array $where
* @return \app\store\model\user\Identity[]|array|Collection
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function getList(array $where)
{
11 months ago
return $this->where($where)->order('month', 'asc')->select();
11 months ago
}
11 months ago
/**
* @notes:详情
* @param $where
* @param array $with
* @return static|array|null
* @author: wanghousheng
*/
public static function detail($where, array $with = [])
{
return static::get($where, $with);
}
11 months ago
11 months ago
}