refactor(order): mengubah nama kolom dari order_at menjadi ordered_at

- menambahkan key ordered_at untuk create
- mengaubah type param di WithMember
- menambahkan clearable di input
This commit is contained in:
Yoga Pangestu 2025-11-05 11:16:56 +07:00
parent b32bcb5f65
commit ac59863be3
4 changed files with 13 additions and 6 deletions

View File

@ -42,7 +42,7 @@ public function columns(): array
})
->html(),
Column::make('Tanggal', 'order_at')
Column::make('Tanggal', 'ordered_at')
->format(fn ($value) => formatDate($value))
->searchable(),
@ -136,7 +136,7 @@ public function columns(): array
public function builder(): Builder
{
return Order::select('orders.id', 'orders.user_id', 'invoice_number', 'customer_id', 'orders.order_at', 'cogs', 'subtotal', 'discount', 'total', 'orders.status', 'channel', 'orders.voucher_id', 'orders.created_at')
return Order::select('orders.id', 'orders.user_id', 'invoice_number', 'customer_id', 'orders.ordered_at', 'cogs', 'subtotal', 'discount', 'total', 'orders.status', 'channel', 'orders.voucher_id', 'orders.created_at')
->with(['user', 'user.employee', 'customer', 'voucher']);
}
}

View File

@ -129,6 +129,7 @@ public function store()
'channel' => $this->channel,
'status' => $this->status,
'payment_method' => $this->payment_method,
'ordered_at' => now(),
]);
// Attach all order items to the newly created order
@ -149,6 +150,7 @@ public function store()
'status' => PaymentStatus::PAID->value,
]);
// Deduct voucher quantity
if ($this->voucher_id) {
$userVoucher = DB::table('user_voucher')
->where('user_id', $member->id)
@ -171,6 +173,7 @@ public function store()
}
}
}
});
return [

View File

@ -29,9 +29,13 @@ public function members()
->toArray();
}
public function updatedFormMemberId(Customer $customer)
public function updatedFormMemberId(?string $member_id = null)
{
$customer->load('user');
$customer = Customer::with('user')->find($member_id);
if (! $customer) {
return;
}
$memberId = $customer->user?->id;

View File

@ -278,9 +278,9 @@ class="text-xs text-gray-400">{{ currency($item->quantity, '') }}
<flux:label>Member</flux:label>
<flux:description>Silakan ketikkan nomor telepon.</flux:description>
<flux:select variant="combobox" placeholder="Pilih Member"
wire:model.live.debounce.500ms="form.member_id">
wire:model.live.debounce.500ms="form.member_id" clear>
<x-slot name="input">
<flux:select.input wire:model.live.debounce.250ms="searchMember" />
<flux:select.input wire:model.live.debounce.250ms="searchMember" clearable/>
</x-slot>
@foreach ($this->members as $member)
<flux:select.option value="{{ $member['id'] }}" key="{{ $member['id'] }}">