diff --git a/app/common/model/MaintenanceCategory.php b/app/common/model/MaintenanceCategory.php index d06c307f..9e42ffe1 100644 --- a/app/common/model/MaintenanceCategory.php +++ b/app/common/model/MaintenanceCategory.php @@ -36,6 +36,14 @@ class MaintenanceCategory extends BaseModel return static::get($categoryId); } + public function catImg(): HasOne + { + $module = self::getCalledModule(); + return $this->hasOne("app\\{$module}\\model\\UploadFile", 'file_id', 'img_id') + ->bind(['img_url' => 'preview_url']); + } + + /** * 获取列表 @@ -47,7 +55,7 @@ class MaintenanceCategory extends BaseModel */ public function getList(array $where = []): \think\Collection { - return $this->where($where) + return $this->where($where)->with(['catImg']) ->order(['sort', $this->getPk()]) ->select(); }