使用上传类型时一切正常,但使用上传多个时出错。

huangapple go评论36阅读模式
英文:

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(&#39;photos&#39;)-&gt;type(&#39;upload&#39;)-&gt;withFiles([&#39;path&#39; =&gt; &#39;productphotos&#39;]);. it upload the images to the /productphotos directory in the public storage.

When trying to change that to CRUD::field(&#39;photos&#39;)-&gt;type(&#39;upload_multiple&#39;)-&gt;withFiles([&#39;path&#39; =&gt; &#39;productphotos&#39;]); 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

&lt;?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 = [
        &#39;category_id&#39;,
        &#39;price&#39;,
        &#39;weight&#39;,
        &#39;quantity&#39;,
        &#39;stock_control&#39;,
        &#39;notes&#39;,
        &#39;age_restricted&#39;,
        &#39;sale_item&#39;,
        &#39;active&#39;,
        &#39;list_index&#39;,
        &#39;photos&#39;
    ];

    public function category() : BelongsTo
    {
        return $this-&gt;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

huangapple
  • 本文由 发表于 2023年7月17日 22:28:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76705478.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定