[英]Laravel Backpack - Upload multiple in PageTemplate
我正在嘗試在頁面編輯表單上上傳多個圖像。 在我的PageTemplates.php中,我有:
$this->crud->addField([
'name' => 'images',
'label' => 'Fotos',
'type' => 'upload_multiple',
'upload' => true,
'disk' => 'uploads',
'hint' => 'Some hint text.',
'fake' => true
]);
在我的Page模型中,我有:
public function setImagessAttribute($value)
{
$attribute_name = "images";
$disk = "uploads";
$destination_path = "images/pages";
$this->uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
}
在config / filesystems.php的 $ disks數組中,我有:
'uploads' => [
'driver' => 'local',
'root' => public_path('uploads'),
],
但是當我嘗試保存頁面時,我遇到了兩個問題:
在我的數據庫extras字段中,我得到了:
"images":[
{
},
{
}
],
我究竟做錯了什么?
執行以下操作后,它工作正常:
$fillable
'fake' => true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.