From f68875c6ad6aa0c1c30b06b4c244ab93ff547f5e Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Wed, 1 Oct 2025 20:47:33 +0700 Subject: [PATCH] fix(perfume): image tidak boleh null sbeagai gantinya jadi array kosong --- app/Livewire/Forms/PerfumeForm.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Livewire/Forms/PerfumeForm.php b/app/Livewire/Forms/PerfumeForm.php index c1a6e65..95c9cb2 100644 --- a/app/Livewire/Forms/PerfumeForm.php +++ b/app/Livewire/Forms/PerfumeForm.php @@ -38,7 +38,7 @@ class PerfumeForm extends Form public array $category_ids = []; - public ?array $image = null; + public array $image = []; public array $outlet_ids = []; @@ -116,9 +116,7 @@ public function store() $perfume->outlets()->attach($this->outlet_ids); - if ($this->image) { - $this->image = $this->mapMediaCollection($perfume->getMedia('image')); - } + $this->uploadMedia($this->image, $perfume, 'image'); }); } @@ -135,8 +133,8 @@ public function update() $this->perfume->outlets()->sync($this->outlet_ids); - $this->syncMedia($data['image'] ?? [], $this->perfume, 'image'); - $this->uploadMedia($data['image'] ?? [], $this->perfume, 'image'); + $this->syncMedia($data['image'], $this->perfume, 'image'); + $this->uploadMedia($data['image'], $this->perfume, 'image'); }); }