user order controller update for show view data
This commit is contained in:
@@ -139,26 +139,36 @@ public function orderDetails($order_id)
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Find invoice for this customer and container
|
||||
// Find container first
|
||||
$container = \App\Models\Container::find($order_id);
|
||||
|
||||
if (!$container) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Container not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Find invoice belonging to this user for this container
|
||||
$invoice = \App\Models\Invoice::where('customer_id', $user->id)
|
||||
->where('container_id', $order_id)
|
||||
->with(['items', 'container'])
|
||||
->where('container_id', $container->id)
|
||||
->with(['items'])
|
||||
->first();
|
||||
|
||||
if (!$invoice) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Order not found'
|
||||
'message' => 'Order not found for this user'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'order' => [
|
||||
'container_id' => $invoice->container->id ?? null,
|
||||
'container_number' => $invoice->container->container_number ?? null,
|
||||
'container_date' => $invoice->container->container_date ?? null,
|
||||
'status' => $invoice->container->status ?? null,
|
||||
'container_id' => $container->id,
|
||||
'container_number' => $container->container_number,
|
||||
'container_date' => $container->container_date,
|
||||
'status' => $container->status,
|
||||
'invoice_id' => $invoice->id,
|
||||
'items' => $invoice->items
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user