refactor: 修改附件下载接口添加分类名称字段输出

This commit is contained in:
2025-04-01 11:44:37 +08:00
parent ee15b4c574
commit 491d2ab55a

View File

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