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`
This commit is contained in:
parent
f563128237
commit
fbeb747fc3
@ -13,6 +13,7 @@ use Filament\Forms\Components\Tabs;
|
|||||||
use Filament\Forms\Components\Tabs\Tab;
|
use Filament\Forms\Components\Tabs\Tab;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
|
|
||||||
class ImportEggAction extends Action
|
class ImportEggAction extends Action
|
||||||
@ -31,7 +32,7 @@ class ImportEggAction extends Action
|
|||||||
$this->authorize(fn () => auth()->user()->can('import egg'));
|
$this->authorize(fn () => auth()->user()->can('import egg'));
|
||||||
|
|
||||||
$this->action(function (array $data, EggImporterService $eggImportService): void {
|
$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)) {
|
if (empty($eggs)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ use Filament\Forms\Components\Tabs\Tab;
|
|||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Tables\Actions\Action;
|
use Filament\Tables\Actions\Action;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
|
|
||||||
class ImportEggAction extends Action
|
class ImportEggAction extends Action
|
||||||
@ -31,7 +32,7 @@ class ImportEggAction extends Action
|
|||||||
$this->authorize(fn () => auth()->user()->can('import egg'));
|
$this->authorize(fn () => auth()->user()->can('import egg'));
|
||||||
|
|
||||||
$this->action(function (array $data, EggImporterService $eggImportService): void {
|
$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)) {
|
if (empty($eggs)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user