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.
72 lines
1.5 KiB
72 lines
1.5 KiB
<?php
|
|
|
|
namespace app\common\model\user;
|
|
|
|
use app\common\enum\user\IdentityEnum;
|
|
use cores\BaseModel;
|
|
use think\Collection;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\DbException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
|
|
class Identity extends BaseModel
|
|
{
|
|
// 定义表名
|
|
protected $name = 'user_identity_price';
|
|
|
|
// 定义主键
|
|
protected $pk = 'identity_id';
|
|
|
|
|
|
/**
|
|
* 追加字段
|
|
* @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 '未知';
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
return $this->where($where)->select();
|
|
}
|
|
|
|
/**
|
|
* @notes:详情
|
|
* @param $where
|
|
* @param array $with
|
|
* @return static|array|null
|
|
* @author: wanghousheng
|
|
*/
|
|
public static function detail($where, array $with = [])
|
|
{
|
|
return static::get($where, $with);
|
|
}
|
|
|
|
|
|
} |