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