@php
$markId = $mark->id;
$bodies = \JustWeCMS\Modules\Auto\Entities\Body::filter()->where('active', 1)->whereHas('model', function($query) use($markId) {
$query->where('mark_id', $markId);
})->orderBy('position')->get();
@endphp
@php
$maxDiscount = 0;
$bodies->each(function($item, $key) use(&$maxDiscount) {
$discount = $item->getMinPrice('price_old') - $item->getMinPrice();
if($discount > $maxDiscount) {
$maxDiscount = $discount;
}
});
@endphp
Новые автомобили {{ $mark->name }}
@php
$bodies = \JustWeCMS\Modules\Auto\Entities\Body::where('active',1)->whereHas('model', function($query) use($markId) {$query->where('mark_id', $markId);})->orderBy('position');
//Если перешли со страницы коммерческого транспорта, то показываем только модели, в которых есть коммерческий транспорт
if( ($from = request()->get('from', null)) === 'COMMERCIAL' ) {
$bodies->where('type_of_car', 'COMMERCIAL');
}
$bodies = $bodies->get();
@endphp
@if(count($bodies))
@foreach($bodies as $bodyItem)
@include(get_view('catalog-car-item', [
'bodyItem' => $bodyItem
]))
@endforeach
@endif