refactor: 修改附件下载接口添加分类名称字段输出
This commit is contained in:
@@ -61,14 +61,29 @@ class Attachment
|
|||||||
{
|
{
|
||||||
$id = request()->param('id');
|
$id = request()->param('id');
|
||||||
|
|
||||||
$attachment = AttachmentModel::withoutField([
|
$attachment = AttachmentModel::with(['category' => function ($query) {
|
||||||
'language_id',
|
$query->field(['id', 'name' => 'category_name']);
|
||||||
'created_at',
|
}])
|
||||||
'updated_at',
|
->field([
|
||||||
'deleted_at'
|
'id',
|
||||||
|
'category_id',
|
||||||
|
'name',
|
||||||
|
'desc',
|
||||||
|
'image',
|
||||||
|
'applicable_to',
|
||||||
|
'support_platform',
|
||||||
|
'attach',
|
||||||
|
'sort',
|
||||||
|
'recommend',
|
||||||
|
'status',
|
||||||
|
'seo_title',
|
||||||
|
'seo_keywords',
|
||||||
|
'seo_desc'
|
||||||
])
|
])
|
||||||
->bypk($id)
|
->bypk($id)
|
||||||
->find();
|
->find()
|
||||||
|
->bindAttr('category', ['category_name'])
|
||||||
|
->hidden(['category']);
|
||||||
if (empty($attachment)) {
|
if (empty($attachment)) {
|
||||||
return error('附件不存在');
|
return error('附件不存在');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user