@extends(get_view('template-main'), [ 'title' => 'Автомобили' ]) @section('content')
@include(get_view('main-marks'))
@include(get_view('filter-form'))
Новые автомобили в наличии
@php $marks = \JustWeCMS\Modules\Auto\Entities\Mark::where('active', 1)->orderBy('position')-> with(['model' => function($query) { $query->where('active', 1); $query->has('body'); }])-> with(['model.body' => function($query) { $query->where('active', 1); $query->orderBy('position'); $query->filter(); }]) ->get(); @endphp @foreach($marks as $mark) @php $bodyCount = 0; $mark->model->map(function ($model) use(&$bodyCount) { $bodyCount += $model->body->count(); }); @endphp @if( $bodyCount !== 0 )
{{ $mark->name }}
    @foreach($mark->model as $model) @foreach($model->body as $bodyItem) @include(get_view('catalog-car-item', [ 'bodyItem' => $bodyItem ])) @endforeach @endforeach
@endif @endforeach
@endsection