update logic

This commit is contained in:
baodev0
2026-06-15 09:11:57 +07:00
parent 9c68273b4a
commit 3243473843
30 changed files with 2502 additions and 24 deletions
+7 -14
View File
@@ -25,13 +25,9 @@ class OrderRepository extends BaseApiRepository implements OrderRepositoryInterf
$addons = $data['addons'] ?? [];
unset($data['addons']);
return OrderItem::create(array_merge(
['order_id' => $orderId],
$data,
// Preserve addon selections as JSON; read again at provisioning time
// to build service_addons records.
['addons_meta' => !empty($addons) ? $addons : null],
));
return OrderItem::create(
array_merge(['order_id' => $orderId], $data, ['addons_meta' => !empty($addons) ? $addons : null]),
);
}
// -------------------------------------------------------------------------
@@ -41,15 +37,15 @@ class OrderRepository extends BaseApiRepository implements OrderRepositoryInterf
public function processPayment(Order $order, string $method): Order
{
$order->update([
'status' => OrderStatus::ACTIVE->value,
'status' => OrderStatus::ACTIVE->value,
'payment_method' => $method,
]);
if ($order->invoice) {
$order->invoice->update([
'status' => InvoiceStatus::PAID->value,
'status' => InvoiceStatus::PAID->value,
'payment_method' => $method,
'paid_at' => now(),
'paid_at' => now(),
]);
}
@@ -62,10 +58,7 @@ class OrderRepository extends BaseApiRepository implements OrderRepositoryInterf
public function hasPendingOrder(int $customerId): bool
{
return $this->model
->where('customer_id', $customerId)
->where('status', OrderStatus::PENDING->value)
->exists();
return $this->model->where('customer_id', $customerId)->where('status', OrderStatus::PENDING->value)->exists();
}
// -------------------------------------------------------------------------