i have that relationship, and the mainproblem is how do i show Product where have relationship with product_image / discounts and render that on blade?
There my Cart class model :
public function products()
{
return $this->belongsTo(Product::class, 'product_id','id');
}
There’s my product class model :
public function discounts()
{
return $this->hasMany(Discount::class, 'product_id', 'id');
}
public function images()
{
return $this->hasMany(ProductImage::class, 'product_id', 'id');
}
public function getProductImage()
{
return $this->images->image_name;
}
This is both whatdiscount and product_images code to returning relationship
public function products()
{
return $this->belongsTo(Product::class, 'product_id','id');
}
and how do i show that on my Cart blade? i’ve use this but still error
@foreach($cart as $data)
@foreach ($data->products as $item)
<th scope="row">
<img src="{{ asset('images/'.$item->image->image ) }}"class="border" style="width:120px;" alt="">
</th>
@endforeach
@endforeach
