【发布时间】:2019-08-19 05:29:14
【问题描述】:
我是 10 月 CMS 的新手。现在我有一个文件附件的问题。在模型中:
public $attachOne = [
'cover_image' => ['System\Models\File']
];
现在在控制器中:
$comic = Comic::with('cover_image)->find($id);
返回:
{
"id": 24,
"title": "Comic example detail",
"description": "Comic example detail",
"total_page": "14",
"cover_image": {
"id": 165,
"disk_name": "5d5a21ca68bf9280597931.png",
"file_name": "img06.png",
"file_size": 142958,
"content_type": "image/png",
"title": null,
"description": null,
"field": "cover_image",
"sort_order": 165,
"created_at": "2019-08-19 04:12:58",
"updated_at": "2019-08-19 04:15:23",
"path": "http://localhost:10080/storage/app/uploads/public/5d5/a21/ca6/5d5a21ca68bf9280597931.png",
"extension": "png"
}
}
我希望cover_image 只返回一些字段,如下所示:
"cover_image": {
"id": 165,
"file_name": "img06.png",
"path": "http://localhost:10080/storage/app/uploads/public/5d5/a21/ca6/5d5a21ca68bf9280597931.png",
}
我该怎么做?
【问题讨论】:
-
你检查我的答案了吗?
标签: laravel octobercms octobercms-backend