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.
61 lines
1.4 KiB
61 lines
1.4 KiB
11 months ago
|
<?php
|
||
|
declare (strict_types=1);
|
||
|
|
||
|
namespace app\common\model\server;
|
||
|
|
||
|
use app\common\model\UploadFile;
|
||
|
use cores\BaseModel;
|
||
|
use think\db\exception\DataNotFoundException;
|
||
|
use think\db\exception\DbException;
|
||
|
use think\db\exception\ModelNotFoundException;
|
||
|
use think\model\relation\HasOne;
|
||
|
|
||
|
class RecoveryCategory extends BaseModel
|
||
|
{
|
||
|
|
||
|
// 定义表名
|
||
|
protected $name = 'server_recovery_category';
|
||
|
|
||
|
// 定义主键
|
||
|
protected $pk = 'category_id';
|
||
|
|
||
|
/**
|
||
|
* 分类图片
|
||
|
* @return HasOne
|
||
|
*/
|
||
|
public function image(): HasOne
|
||
|
{
|
||
|
return $this->hasOne(UploadFile::class, 'file_id', 'image_id');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @notes:分类详情
|
||
|
* @param $where
|
||
|
* @param array $with
|
||
|
* @return static|array|null
|
||
|
* @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();
|
||
|
}
|
||
|
}
|