From fbeb747fc34e5f3dbcebcf5b579cc19c03d6a0d0 Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> Date: Mon, 17 Mar 2025 18:07:36 +0100 Subject: [PATCH] Fix `ImportEggAction` (#1110) * `Arr::Wrap` `data.files` cause if its unique its a string * Use `data.url` first so it gets overwritten by `data.files` --- app/Filament/Components/Actions/ImportEggAction.php | 3 ++- app/Filament/Components/Tables/Actions/ImportEggAction.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Filament/Components/Actions/ImportEggAction.php b/app/Filament/Components/Actions/ImportEggAction.php index c60df54b5..c6e3b8b58 100644 --- a/app/Filament/Components/Actions/ImportEggAction.php +++ b/app/Filament/Components/Actions/ImportEggAction.php @@ -13,6 +13,7 @@ use Filament\Forms\Components\Tabs; use Filament\Forms\Components\Tabs\Tab; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; +use Illuminate\Support\Arr; use Livewire\Features\SupportFileUploads\TemporaryUploadedFile; class ImportEggAction extends Action @@ -31,7 +32,7 @@ class ImportEggAction extends Action $this->authorize(fn () => auth()->user()->can('import egg')); $this->action(function (array $data, EggImporterService $eggImportService): void { - $eggs = array_merge($data['files'], collect($data['urls'])->flatten()->whereNotNull()->unique()->all()); + $eggs = array_merge(collect($data['urls'])->flatten()->whereNotNull()->unique()->all(), Arr::wrap($data['files'])); if (empty($eggs)) { return; } diff --git a/app/Filament/Components/Tables/Actions/ImportEggAction.php b/app/Filament/Components/Tables/Actions/ImportEggAction.php index 3bfba1f5a..426ba46b9 100644 --- a/app/Filament/Components/Tables/Actions/ImportEggAction.php +++ b/app/Filament/Components/Tables/Actions/ImportEggAction.php @@ -13,6 +13,7 @@ use Filament\Forms\Components\Tabs\Tab; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; use Filament\Tables\Actions\Action; +use Illuminate\Support\Arr; use Livewire\Features\SupportFileUploads\TemporaryUploadedFile; class ImportEggAction extends Action @@ -31,7 +32,7 @@ class ImportEggAction extends Action $this->authorize(fn () => auth()->user()->can('import egg')); $this->action(function (array $data, EggImporterService $eggImportService): void { - $eggs = array_merge($data['files'], collect($data['urls'])->flatten()->whereNotNull()->unique()->all()); + $eggs = array_merge(collect($data['urls'])->flatten()->whereNotNull()->unique()->all(), Arr::wrap($data['files'])); if (empty($eggs)) { return; }