From 99d585864111521bfef79ba69d8764ce8e6f821d Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Fri, 3 Oct 2025 07:59:33 +0700 Subject: [PATCH] reafctor(perfume): model brand diubah menjadi brand_id --- app/Livewire/Forms/Studio/Catalog/PerfumeForm.php | 10 +++++----- .../livewire/studio/catalog/perfume/form.blade.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php b/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php index 7301562..29c29e8 100644 --- a/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php +++ b/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php @@ -20,7 +20,7 @@ class PerfumeForm extends Form public string $sku = ''; - public ?string $brand = null; + public ?string $brand_id = null; public string $cost_price = ''; @@ -52,7 +52,7 @@ public function rules(): array 'max:20', Rule::unique('perfumes', 'sku')->ignore($this->perfume), ], - 'brand' => ['nullable', Rule::exists('brands', 'id')], + 'brand_id' => ['nullable', Rule::exists('brands', 'id')], 'cost_price' => ['required', new UnsignedInteger], 'sale_price' => ['required', new UnsignedInteger], 'base_notes' => ['nullable', 'string', 'max:255'], @@ -72,7 +72,7 @@ public function validationAttributes(): array { return [ 'name' => 'nama', - 'brand' => 'merek', + 'brand_id' => 'merek', 'cost_price' => 'harga beli', 'sale_price' => 'harga jual', 'description' => 'deskripsi', @@ -90,7 +90,7 @@ public function setPerfume(Perfume $perfume) $this->name = $perfume->name; $this->sku = $perfume->sku; - $this->brand = $perfume->brand_id; + $this->brand_id = $perfume->brand_id; $this->cost_price = $perfume->cost_price; $this->sale_price = $perfume->sale_price; $this->base_notes = $perfume->base_notes; @@ -150,7 +150,7 @@ private function prepareSavedData() 'top_notes' => $this->top_notes, 'description' => $this->description, 'concentration' => $this->concentration, - 'brand_id' => $this->brand, + 'brand_id' => $this->brand_id, 'category_ids' => $this->category_ids, 'outlet_ids' => $this->outlet_ids, 'image' => $this->image, diff --git a/resources/views/livewire/studio/catalog/perfume/form.blade.php b/resources/views/livewire/studio/catalog/perfume/form.blade.php index f69d690..d743a18 100644 --- a/resources/views/livewire/studio/catalog/perfume/form.blade.php +++ b/resources/views/livewire/studio/catalog/perfume/form.blade.php @@ -35,7 +35,7 @@
+ label="Merek" wire:model.live.debounce.500ms="form.brand_id"> @foreach ($brands as $key => $value) {{ $value }}