Skip to content
Advertisement

How to show specific order details and all products which belongs only to that specific order on same view

How to show specific order details and all products which belongs only to that specific order on same view? Trying this, but getting empty array when doing dd(). OrderController:

JavaScript

web.php

JavaScript

Product.php

JavaScript

Order.php

JavaScript

Advertisement

Answer

I would suggest to change the name of your route param to id to consistency and readability

JavaScript

In view generate url for your route as

JavaScript

And in controller you can get order details along with related products as

JavaScript

And in view you can get collection of products from $order->products

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement