From d560249789dae60a9afb56ecd8643554047c6278 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 1 Apr 2025 11:52:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E8=AF=A6=E6=83=85=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/Video.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/v1/Video.php b/app/admin/controller/v1/Video.php index 969039e0..a37a9dcd 100644 --- a/app/admin/controller/v1/Video.php +++ b/app/admin/controller/v1/Video.php @@ -61,13 +61,18 @@ class Video */ public function read() { - $video = VideoModel::withoutField([ + $video = VideoModel::with(['category' => function($query) { + $query->field(['id', 'name' => 'category_name']); + }]) + ->withoutField([ 'created_at', 'updated_at', 'deleted_at' ]) ->bypk(request()->param('id')) - ->find(); + ->find() + ->bindAttr('category', ['category_name']) + ->hidden(['category']); if (empty($video)) { return error('视频不存在'); }