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('视频不存在'); }