From efdff6130658b060c8935f6500e896a18d67cb9c Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 1 Apr 2025 11:44:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8B=E8=BD=BD=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=90=8D=E7=A7=B0=E5=AD=97=E6=AE=B5=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/Attachment.php | 27 ++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/v1/Attachment.php b/app/admin/controller/v1/Attachment.php index 611c2621..2775c476 100644 --- a/app/admin/controller/v1/Attachment.php +++ b/app/admin/controller/v1/Attachment.php @@ -61,14 +61,29 @@ class Attachment { $id = request()->param('id'); - $attachment = AttachmentModel::withoutField([ - 'language_id', - 'created_at', - 'updated_at', - 'deleted_at' + $attachment = AttachmentModel::with(['category' => function ($query) { + $query->field(['id', 'name' => 'category_name']); + }]) + ->field([ + 'id', + 'category_id', + 'name', + 'desc', + 'image', + 'applicable_to', + 'support_platform', + 'attach', + 'sort', + 'recommend', + 'status', + 'seo_title', + 'seo_keywords', + 'seo_desc' ]) ->bypk($id) - ->find(); + ->find() + ->bindAttr('category', ['category_name']) + ->hidden(['category']); if (empty($attachment)) { return error('附件不存在'); }