繁体   English   中英

Laravel Backpack - 在PageTemplate中上传多个

[英]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
  • 从PageTemplates.php中删除'fake' => true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM