in my Laravel project i get this database structure:
Products
- Id
- Name
Orders
- Id
- Total
Order_Product
- Product_id (nullable)
- Order_Id
- Details
In my Order model I make belongsToMany retaltionship with Product model:
public function products() {
return $this->belongsToMany(Product::class)->withPivot('Details');
}
The Problem is when I try to get the Order Products Collection
$order->products();
I don't get rows with nullable product_id, Any solution please ? Thank you.