Laravel-medialibrary: addMultipleMediaFromRequest don't recognize array of same name

Created on 20 May 2019  路  8Comments  路  Source: spatie/laravel-medialibrary

Hello there, after multiple tries, looks like the library doesn't take the case where multiple files from the same request under an array.

Example from library :

$fileAdders = $this->model
    ->addMultipleMediaFromRequest(['file-one', 'file-two'])
    ->each(function ($fileAdder) {
        $fileAdder->toMediaCollection();
    });

What I would like to do :

$fileAdders = $this->model
    ->addMultipleMediaFromRequest(['file[]']) // or (, 'file[0]', 'file[1]', etc...)
    ->each(function ($fileAdder) {
        $fileAdder->toMediaCollection();
    });

I know it looks like a specific use case, but I don't know if it's just me that didn't find anything in the source of the lib, or that there is nothing possible for that for now.

Cordially,
Epistol

good first issue help wanted

Most helpful comment

/claim ... I want to do this.

All 8 comments

Hi Epistol

Sounds like a good feature we could add. Though I'm unsure about the file[] notation. To me personally it would make more sense to use Laravel's naming conventions and use file.*. That's an implementation detail though.

Do you think you'd want to give it a try and submit a PR for this? You'd need to make changes in \Spatie\MediaLibrary\FileAdder\FileAdderFactory::createMultipleFromRequest. No pressure though, let me know if you're not up for it and I'll be happy to make a PR myself.

/claim ... I want to do this.

Go for it!

@brendt please review the pull request

Can you provide a link to the PR?

Looks like https://github.com/spatie/laravel-medialibrary/pull/1471 but travis ci doesn't seem happy with it :')

@brendt Yes because of this issue 1472 and I submitted it to mention that there is a problem with links and @riasvdv mentioned that it's fixed

Was this page helpful?
0 / 5 - 0 ratings