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

52 lines
1.2 KiB

11 months ago
<?php
namespace app\api\model\Server;
use app\api\model\UploadFile;
use app\common\model\ServerCategory as BaseServerCategory;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\model\relation\HasOne;
class ServerCategory extends BaseServerCategory
{
/**
* 隐藏字段
* @var array
*/
protected $hidden = [
'store_id',
'create_time',
'update_time',
'status',
'image_id',
];
/**
* 分类图片
* @return HasOne
*/
public function image(): HasOne
{
return $this->hasOne(UploadFile::class, 'file_id', 'image_id')
->bind(['image_url' => 'preview_url']);
}
/**
* @notes:获取全部记录
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function list(): array
{
return $this->with(['image'])
11 months ago
->where(['status' => 1])
11 months ago
->order(['sort', 'create_time'])
->select()
->toArray();
}
}