英文:
When using upload type everything goes well, when using upload_multiple getting error
问题
使用以下代码时:CRUD::field('photos')->type('upload')->withFiles(['path' => 'productphotos']);
,它会将图片上传到公共存储中的/productphotos目录。
当尝试将其更改为CRUD::field('photos')->type('upload_multiple')->withFiles(['path' => 'productphotos']);
后,提交时我收到以下错误消息:Too few arguments to function Backpack\CRUD\app\Library\Uploaders\Uploader::getPreviousFiles(),0个参数传递给vendor/backpack/crud/src/app/Library/Uploaders/MultipleFiles.php的第22行,需要1个参数
。
有人知道如何修复此错误,以便我可以继续吗?我已经尝试仅使用Laravel Backpack文档中的设置,但仍然收到此错误消息。
谢谢
编辑:
版本:
BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.0.0
backpack/crud: 6.0.4
backpack/generators: v4.0.0
backpack/permissionmanager: 7.0.0
backpack/theme-coreuiv2: 1.1.3
ProductModel
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Product extends Model
{
use CrudTrait;
use HasFactory;
protected $fillable = [
'category_id',
'price',
'weight',
'quantity',
'stock_control',
'notes',
'age_restricted',
'sale_item',
'active',
'list_index',
'photos'
];
public function category() : BelongsTo
{
return $this->belongsTo(Category::class);
}
}
英文:
when using this: CRUD::field('photos')->type('upload')->withFiles(['path' => 'productphotos']);
. it upload the images to the /productphotos directory in the public storage.
When trying to change that to CRUD::field('photos')->type('upload_multiple')->withFiles(['path' => 'productphotos']);
on submit I am getting this error: Too few arguments to function Backpack\CRUD\app\Library\Uploaders\Uploader::getPreviousFiles(), 0 passed in vendor/backpack/crud/src/app/Library/Uploaders/MultipleFiles.php on line 22 and exactly 1 expected
Does anyone know how to fix this error so I can continue? I've already tried to only use the settings from the Laravel Backpack docs but still get this error.
Thanks
EDIT:
Version:
### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.0.0
backpack/crud: 6.0.4
backpack/generators: v4.0.0
backpack/permissionmanager: 7.0.0
backpack/theme-coreuiv2: 1.1.3
ProductModel
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Product extends Model
{
use CrudTrait;
use HasFactory;
protected $fillable = [
'category_id',
'price',
'weight',
'quantity',
'stock_control',
'notes',
'age_restricted',
'sale_item',
'active',
'list_index',
'photos'
];
public function category() : BelongsTo
{
return $this->belongsTo(Category::class);
}
}
答案1
得分: 0
这是 Laravel Backpack 中的一个错误,将在版本 6.0.6 中修复。
英文:
It was an bug in Laravel Backpack which is gonna be fixed in version 6.0.6
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论