Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.16k stars 892 forks source link

[Bug] Multiple upload in a relationship does not work with Spatie/MediaLibrary #5625

Closed manfield closed 2 months ago

manfield commented 2 months ago

Bug report

What I did

While this code works properly on a CRUD form with a relation to a submodel:

        $this->crud->addField(
            [
                'label'     => "Content",
                'name'  => 'content_blocks',
                'type' => 'relationship',
                'subfields' => [
                    [
                        'name' => 'title',
                        'type' => 'text'
                    ],
                    [
                        'name' => 'text',
                        'type' => 'text'
                    ],
                    [
                        'name' => 'gallery',
                        'type' => 'upload_multiple',
                        'withFiles' => true
                    ],
                ],

            ]
        );

https://github.com/user-attachments/assets/8a2e6295-a185-4f1b-a1a9-5bf940a41188

What happens with Spatie/MediaLibary

using Spatie/MediaLibrary, like this - for example


      $this->crud->addField(
            [
                'label'     => "Content",
                'name'  => 'content_blocks',
                'type' => 'relationship',
                'subfields' => [
                    [
                        'name' => 'title',
                        'type' => 'text'
                    ],
                    [
                        'name' => 'text',
                        'type' => 'text'
                    ],
                    [
                        'name' => 'gallery',
                        'type' => 'upload_multiple',
                        'withMedia' => ['displayConversions' => 'thumbnail'],
                    ],
                ],

            ]
        );

brings to the following behaviour:

https://github.com/user-attachments/assets/8795f0e5-437e-41b3-86e4-61d6b31bb923

What I expected to happen

Images are processed through the MediaLibrary as usually happens with an "image" type field

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.3.9

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, ast, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, igbinary, intl, exif, msgpack, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, Zend OPcache, xdebug

### LARAVEL VERSION:
11.20.0.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.5
backpack/crud: 6.7.25
backpack/devtools: 3.1.5
backpack/generators: v4.0.5
backpack/language-switcher: 2.0.0
backpack/medialibrary-uploaders: 1.2.0
backpack/permissionmanager: 7.2.1
backpack/pro: 2.2.12
backpack/theme-tabler: 1.2.11
backpack/translation-manager: 1.0.3
karandatwani92 commented 2 months ago

Hey @manfield

We are aware of the issue. A major refactoring of the Backpack Uploader is being done to cover this and other uploader-related problems. It's a BIG PR, which may take some time. Sorry for the inconvenience.

You can subscribe to our newsletter for the Backpack Progress report and other updates.