File: //home/armgroup/libs/resources/views/frontend/compare/index.blade.php
@extends('layouts.app')
@section('header')
<link rel="stylesheet" href="{{ asset('css/compare.css?v=0.0.3') }}"/>
@endsectio
@section('content')
<div class="container-fluid my-5 body-content">
<div class="card p-5">
<div class="row">
<div class="col-12 p-0">
<h2 class="text-center">
<span>مقایسه</span>
</h2>
</div>
</div>
<hr>
<div class="row">
@foreach($products as $product)
<div class="col-3">
<div class="card">
<form class="w-25 mx-auto" action="{{ route('compare.destroy', $product->id) }}" method="POST">
@csrf
@method('DELETE')
<button class="btn btn-sm btn-danger w-100" type="submit"><span class="fa fa-times"></span> حذف</button>
</form>
<a href="{{ route('products.show', $product->slug) }}">
<img class="card-img-top" src="{{ asset($product->image) }}" alt="{{ $product->name }}">
</a>
<div class="card-body">
<h5 class="card-title">
<a href="{{ route('products.show', $product->slug) }}" class="text-info">
{{ $product->name }}
</a>
</h5>
<p class="card-text">
<table class="table">
<tr>
<th>برند</th>
<td>{{ $product->brand->name ?: '-' }}</td>
</tr>
@foreach($category->attributeGroups as $attributeGroup)
<tr>
<th colspan="2" class="text-secondary text-center">{{ $attributeGroup->name }}</th>
</tr>
@foreach($attributeGroup->attributes as $attribute)
<tr>
<th>{{ $attribute->name }}</th>
<td>{{ $product->values->firstWhere('attribute_id', $attribute->id)?->value ?: '-' }}</td>
</tr>
@endforeach
@endforeach
</table>
</p>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
@endsection