update logic
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user