I have three tables - users
, products
and orders
There is a relation between users
and orders
(users
has many orders
).
orders
table contains product_id
and user_id
column.
Now I want to access the product details of orders for a user.
What I am trying:
public function myOrders(){
$orders = Auth::user()->orders->pluck('product_id');
$products = Product::find($orders);
return view('shop.myorders', compact('products'));
}
But this is not working. Can anyone help me? What other way can be better to achieve this?