مقارنة اجهزة ال {{ $category->title }}
@foreach ($spec_categories as $spec_category)
{{ $spec_category->title }}
@php
$wrap = function ($content) {
return trim($content) === strip_tags($content)
? '
' . e($content) . ''
: '
' . $content . '';
};
$getRecords = function ($spec, $category, $upgradable) {
$itemsIds = $spec->items->pluck('id');
if ($upgradable) {
return \App\Models\Upgrade::where('spec_category_id', $category->id)
->where('is_active', 1)
->whereHas('items', function ($q) use ($itemsIds) {
$q->whereIn('item_id', $itemsIds);
})
->get();
}
return \App\Models\Spec::where('spec_category_id', $category->id)
->whereHas('items', function ($q) use ($itemsIds) {
$q->whereIn('item_id', $itemsIds);
})
->orderBy('order')
->get();
};
$spec1 = \App\Models\Spec::where('title', request('c1', $c_items[0]->title))->first();
$records1 = $getRecords($spec1, $spec_category, $spec_category->is_upgradable);
$specs_col_1 = [];
foreach ($records1 as $rec) {
$specs_col_1[] = $wrap($rec->description ?: $rec->title);
}
if (!$specs_col_1) $specs_col_1[] = '
لا يوجد';
$spec2 = \App\Models\Spec::where('title', request('c2', $c_items[1]->title))->first();
$records2 = $getRecords($spec2, $spec_category, $spec_category->is_upgradable);
$specs_col_2 = [];
foreach ($records2 as $rec) {
$specs_col_2[] = $wrap($rec->description ?: $rec->title);
}
if (!$specs_col_2) $specs_col_2[] = '
لا يوجد';
$specs_col_3 = [];
if ($agent->isDesktop()) {
$spec3 = \App\Models\Spec::where('title', request('c3', $c_items[2]->title))->first();
$records3 = $getRecords($spec3, $spec_category, $spec_category->is_upgradable);
foreach ($records3 as $rec) {
$specs_col_3[] = $wrap($rec->description ?: $rec->title);
}
if (!$specs_col_3) $specs_col_3[] = '
لا يوجد';
}
$html_1 = implode('', $specs_col_1);
$html_2 = implode('', $specs_col_2);
$html_3 = implode('', $specs_col_3);
@endphp
@if (
(!$agent->isDesktop() && $html_1 === $html_2) ||
($agent->isDesktop() && $html_1 === $html_2 && $html_2 === $html_3)
)
@else
@if ($agent->isDesktop())
@endif
@endif
@endforeach