{{-- Вьюха: Форма создания и редактирования автомобиля (единая для create и edit) Создана: 2026-05-06 Контроллер: Admin\CarController::create() / edit() / store() / update() Переменные: $car (Car|null — null при создании), $dictSections (коллекция, индексирована по code) Partials (в admin/cars/partials/): _section_main, _section_tech, _section_price, _section_desc_opts, _section_photos JS (в @push('js')): модели грузятся динамически из $makeModels JSON, select Модель заблокирован до выбора Марки; обновление label у custom-file-input Плагин: Select2 для полей "Марка" и "Модель" --}} @extends('admin.layout') @section('title', isset($car) ? 'Редактировать автомобиль' : 'Добавить автомобиль') @section('content_header')

{{ isset($car) ? 'Редактировать автомобиль #' . $car->id : 'Добавить автомобиль' }}

Назад
@stop @section('breadcrumb') @stop @section('content') @php $car = $car ?? null; $v = fn($field, $default = null) => old($field, $car?->$field ?? $default); $makesList = $dictSections->get('makes'); $bodyTypes = $dictSections->get('body_types')?->values ?? collect(); $countries = $dictSections->get('countries')?->values ?? collect(); $cities = $dictSections->get('cities')?->values ?? collect(); $colorsExt = $dictSections->get('colors_ext')?->values ?? collect(); $colorsInt = $dictSections->get('colors_int')?->values ?? collect(); $engineVols = $dictSections->get('engine_volumes')?->values ?? collect(); $optionsList = $dictSections->get('options')?->values ?? collect(); $makes = $makesList?->allValues()->whereNull('parent_id')->with('children')->get() ?? collect(); // Данные для JS: { "Toyota": ["Camry","RAV4",...], "BMW": [...], ... } // Передаём в @push('js') чтобы не гонять модели через data-атрибуты тысячи option-тегов $makeModels = $makes->mapWithKeys(fn($m) => [ $m->value => $m->children->pluck('value')->all(), ])->all(); $platforms = $dictSections->get('platforms')?->values ?? collect(); $carOptions = is_array($car?->options) ? $car->options : (json_decode($car?->options ?? '[]', true) ?? []); @endphp
@csrf @if($car) @method('PUT') @endif @if($errors->any())
@endif @include('admin.cars.partials._section_main') @include('admin.cars.partials._section_tech') @include('admin.cars.partials._section_price') @include('admin.cars.partials._section_desc_opts') @include('admin.cars.partials._section_photos')
Отмена
@stop @section('plugins.Select2', true) @push('js') @endpush