refactor: 修改视频详情接口添加分类名称字段输出

This commit is contained in:
2025-04-01 11:52:23 +08:00
parent ff3f2fe428
commit d560249789

View File

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