feat: update order timestamps when status is set to completed

This commit is contained in:
Yoga Pangestu 2026-08-27 23:57:42 +07:00
parent 31d286b702
commit 5927fc4e56

View File

@ -427,6 +427,17 @@ public function updateStatus(Order $order, string $status): Order
$order->update(['status' => $status]);
if ($status === OrderStatus::COMPLETED->value) {
$now = now();
DB::table('orders')
->where('id', $order->id)
->update([
'created_at' => $now,
'updated_at' => $now,
]);
$order->refresh();
}
if (in_array($status, [OrderStatus::CANCELLED->value, OrderStatus::REFUNDED->value]) && ! in_array($oldStatus, [OrderStatus::CANCELLED->value, OrderStatus::REFUNDED->value])) {
$order->load('orderItems');
$stockType = $order->orderItems->first()?->stock_quality?->value ?? ProductStockQuality::GOOD->value;