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/ServerCategory.php

58 lines
1.3 KiB

11 months ago
<?php
namespace app\common\model;
use cores\BaseModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\model\relation\HasOne;
class ServerCategory extends BaseModel
{
// 定义表名
protected $name = 'server_category';
// 定义主键
protected $pk = 'category_id';
/**
* 分类图片
* @return HasOne
*/
public function image(): HasOne
{
return $this->hasOne('UploadFile', 'file_id', 'image_id');
}
/**
* @notes:分类详情
* @param $where
* @param array $with
11 months ago
* @return static|array|null
11 months ago
* @author: wanghousheng
*/
public static function detail($where, array $with = [])
{
return static::get($where, $with);
}
/**
* @notes:获取全部记录
* @param array $where
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function getList(array $where = []): array
{
$where = $this->setQueryDefaultValue($where);
return $this->with(['image'])
->where($where)
->order(['sort', 'create_time'])
->select()
->toArray();
}
}