@extends("layout.app") @section("content")

مقارنة اجهزة ال {{ $category->title }}

@if ($agent->isDesktop())
@endif
@php $latest_item = \App\Models\Spec::where('title', request('c1', $c_items[0]->title))->first()->items()->latest()->first(); $sub_category1 = $latest_item->category; $colors_sorted = $latest_item->colors->sortBy(function ($q) { return $q->color->order; }); @endphp
@foreach ($latest_item->item_colors as $color) @endforeach @if ($colors_sorted->count())
@foreach ($colors_sorted as $color)
quantity == 0) title="غير متوفر" @endif style="display:block;margin:0 auto;background:{{ $color->color->color }}" class="color-chooser" type="radio" id="c1-{{ $color->color->id }}" name="c1-color-{{ $latest_item->id }}" value="{{ $color->color->id }}" @if ($loop->first) checked @endif>
@endforeach
@endif
@php $latest_item = \App\Models\Spec::where('title', request('c2', $c_items[1]->title))->first()->items()->latest()->first(); $sub_category2 = $latest_item->category; $colors_sorted = $latest_item->colors->sortBy(function ($q) { return $q->color->order; }); @endphp
@foreach ($latest_item->item_colors as $color) @endforeach @if ($colors_sorted->count())
@foreach ($colors_sorted as $color)
quantity == 0) title="غير متوفر" @endif style="display:block;margin:0 auto;background:{{ $color->color->color }}" class="color-chooser" type="radio" id="c2-{{ $color->color->id }}" name="c2-color-{{ $latest_item->id }}" value="{{ $color->color->id }}" @if ($loop->first) checked @endif>
@endforeach
@endif
@if ($agent->isDesktop())
@php $latest_item = \App\Models\Spec::where('title', request('c3', $c_items[2]->title))->first()->items()->latest()->first(); $sub_category3 = $latest_item->category; $colors_sorted = $latest_item->colors->sortBy(function ($q) { return $q->color->order; }); @endphp
@foreach ($latest_item->item_colors as $color) @endforeach @if ($colors_sorted->count())
@foreach ($colors_sorted as $color)
quantity == 0) title="غير متوفر" @endif style="display:block;margin:0 auto;background:{{ $color->color->color }}" class="color-chooser" type="radio" id="c3-{{ $color->color->id }}" name="c3-color-{{ $latest_item->id }}" value="{{ $color->color->id }}" @if ($loop->first) checked @endif>
@endforeach
@endif
@endif
@php $tab1 = \App\Models\Spec::where('title', request('c1', $c_items[0]->title))->first(); $tab2 = \App\Models\Spec::where('title', request('c2', $c_items[1]->title))->first(); @endphp
@if ($sub_category1->is_active) اطلب @endif
@if ($sub_category2->is_active) اطلب @endif
@if ($agent->isDesktop()) @php $tab3 = \App\Models\Spec::where('title', request('c3', $c_items[2]->title))->first(); @endphp
@if ($sub_category3->is_active) اطلب @endif
@endif
@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) )
      {!! $html_1 !!}
    @else
      {!! $html_1 !!}
      {!! $html_2 !!}
    @if ($agent->isDesktop())
      {!! $html_3 !!}
    @endif @endif

    @endforeach
    @endsection @section("scripts") @endsection