From afa732300222a9a6b9fe56e6780068645d9af6e1 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 16 Oct 2025 21:16:21 +0700 Subject: [PATCH] refactor(product): update cost and sale price handling in form and mask cost price display --- .../Datatable/Studio/Catalog/ProductsTable.php | 3 ++- app/Livewire/Forms/Studio/Catalog/ProductForm.php | 4 ++-- .../livewire/studio/catalog/product/form.blade.php | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php b/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php index 115e73a..6b047da 100644 --- a/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php @@ -8,6 +8,7 @@ use App\Traits\Datatable\WithPrependColumn; 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; @@ -37,7 +38,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/ProductForm.php b/app/Livewire/Forms/Studio/Catalog/ProductForm.php index e28c75e..c8383d2 100644 --- a/app/Livewire/Forms/Studio/Catalog/ProductForm.php +++ b/app/Livewire/Forms/Studio/Catalog/ProductForm.php @@ -111,8 +111,8 @@ private function prepareSavedData() return [ 'name' => $this->name, 'sku' => $this->sku, - 'cost_price' => $this->cost_price, - 'sale_price' => $this->sale_price, + 'cost_price' => replaceCurrency($this->cost_price), + 'sale_price' => replaceCurrency($this->sale_price), 'description' => $this->description, 'outlet_ids' => $this->outlet_ids, 'image' => $this->image, diff --git a/resources/views/livewire/studio/catalog/product/form.blade.php b/resources/views/livewire/studio/catalog/product/form.blade.php index 66ce8ee..1b1944c 100644 --- a/resources/views/livewire/studio/catalog/product/form.blade.php +++ b/resources/views/livewire/studio/catalog/product/form.blade.php @@ -20,15 +20,15 @@
Nama * - SKU * - + @@ -56,8 +56,8 @@
+ placeholder="Air Zamzam adalah air suci yang berasal dari sumur Zamzam di Masjidil Haram, Makkah, Arab Saudi" + auotocomplete="off" class="**:data-[slot=content]:min-h-[100px]!" />