diff --git a/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php b/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php index 440fb6c..741f1f8 100644 --- a/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php @@ -8,6 +8,7 @@ use App\Traits\WithMediaHandler; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\Blade; +use Illuminate\Support\Str; use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Columns\ArrayColumn; @@ -38,7 +39,7 @@ public function columns(): array ->html(), Column::make('Harga Beli', 'cost_price') - ->label(fn ($row, $column) => currency($row->cost_price, 'Rp')) + ->label(fn ($row, $column) => Str::mask(currency($row->cost_price, 'Rp'), '*', 2)) ->searchable() ->sortable(), diff --git a/app/Livewire/Forms/Studio/Catalog/BottleForm.php b/app/Livewire/Forms/Studio/Catalog/BottleForm.php index 684ee03..c1cfec5 100644 --- a/app/Livewire/Forms/Studio/Catalog/BottleForm.php +++ b/app/Livewire/Forms/Studio/Catalog/BottleForm.php @@ -74,13 +74,7 @@ public function store() $this->validate(); DB::transaction(function () { - $bottle = Bottle::create([ - 'name' => $this->name, - 'size' => $this->size, - 'cost_price' => $this->cost_price, - 'sale_price' => $this->sale_price, - 'description' => $this->description, - ]); + $bottle = Bottle::create($this->prepareSavedData()); $bottle->outlets()->attach($this->outlet_ids); @@ -93,18 +87,23 @@ public function update() $this->validate(); DB::transaction(function () { - $this->bottle->update([ - 'name' => $this->name, - 'size' => $this->size, - 'cost_price' => $this->cost_price, - 'sale_price' => $this->sale_price, - 'description' => $this->description, - ]); + $this->bottle->update($this->prepareSavedData()); - $this->bottle->outlets()->attach($this->outlet_ids); + $this->bottle->outlets()->sync($this->outlet_ids); $this->syncMedia($this->image, $this->bottle, 'image'); $this->uploadMedia($this->image, $this->bottle, 'image'); }); } + + private function prepareSavedData(): array + { + return [ + 'name' => $this->name, + 'size' => $this->size, + 'cost_price' => replaceCurrency($this->cost_price), + 'sale_price' => replaceCurrency($this->sale_price), + 'description' => $this->description, + ]; + } } diff --git a/app/Livewire/Studio/Catalog/Bottle/Edit.php b/app/Livewire/Studio/Catalog/Bottle/Edit.php index 242d555..bb0fb8c 100644 --- a/app/Livewire/Studio/Catalog/Bottle/Edit.php +++ b/app/Livewire/Studio/Catalog/Bottle/Edit.php @@ -5,6 +5,7 @@ use App\Livewire\Forms\Studio\Catalog\BottleForm; use App\Models\Bottle; use App\Models\Outlet; +use App\Traits\WithAuthorization; use App\Traits\WithOutletSelector; use App\Traits\WithToast; use App\Traits\WithUpdatedData; @@ -14,7 +15,7 @@ #[Title('Ubah Botol')] class Edit extends Component { - use WithOutletSelector, WithToast, WithUpdatedData; + use WithAuthorization, WithOutletSelector, WithToast, WithUpdatedData; public BottleForm $form; diff --git a/resources/views/livewire/studio/catalog/bottle/form.blade.php b/resources/views/livewire/studio/catalog/bottle/form.blade.php index 234652d..5495eff 100644 --- a/resources/views/livewire/studio/catalog/bottle/form.blade.php +++ b/resources/views/livewire/studio/catalog/bottle/form.blade.php @@ -20,15 +20,15 @@
Nama * - Ukuran * - + @@ -56,8 +56,8 @@
+ placeholder="Botol Le Labo memiliki desain yang minimalis dan elegan, khas gaya modern klasik" + auotocomplete="off" class="**:data-[slot=content]:min-h-[100px]!" />