@php $isEdit = isset($listing) && $listing; $formAction = $isEdit ? route('dealers.listings.update', $listing->id) : route('dealers.listings.store'); $method = $isEdit ? 'PUT' : 'POST'; // Get existing values for edit mode $spec = $isEdit ? $listing->specification : null; $existingFeatures = $isEdit ? $listing->features->pluck('id')->toArray() : []; $existingImages = $isEdit ? $listing->image_url ?? [] : []; $existingFinancing = $isEdit ? $listing->financing_options ?? [] : []; // Get features $safetyFeatures = \App\Models\VehicleFeature::where('category', 'safety')->get(); $comfortFeatures = \App\Models\VehicleFeature::where('category', 'comfort')->get(); $entertainmentFeatures = \App\Models\VehicleFeature::where('category', 'entertainment')->get(); @endphp