refactor: 修改附件下载接口添加分类名称字段输出
This commit is contained in:
@@ -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('附件不存在');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user