From 61cf9835dcbf45116f90b2d1478da3fa6f63885a Mon Sep 17 00:00:00 2001 From: bruce <1272542526@qq.com> Date: Thu, 21 Mar 2024 10:09:21 +0800 Subject: [PATCH] update --- app/common/model/MaintenanceCategory.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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(); }