@props([ 'title' => __('home.featured.title'), 'subtitle' => __('home.featured.subtitle'), 'properties' => [], 'sliderClass' => 'feature_property_slider' ])
@if(count($properties) > 0) @foreach($properties as $property) @php // Get property image (default image or first image) - use thumbnails for listings $propertyImage = 'images/property/fp1.jpg'; if ($property->images && $property->images->count() > 0) { $defaultImage = $property->images->where('is_default', true)->first(); $imagePath = $defaultImage ? $defaultImage->image : $property->images->first()->image; if ($imagePath) { // Extract filename from path if it includes directory $filename = basename($imagePath); $propertyImage = asset( 'files/thumbnails/' . $filename ); } } // Get property title from description $propertyTitle = 'Property Title'; if ($property->descriptions && $property->descriptions->count() > 0) { $description = $property->descriptions->first(); // Extract title from description (first line or first 50 chars) $propertyTitle = $description->description ? (strlen($description->description) > 50 ? substr($description->description, 0, 50) . '...' : $description->description) : 'Property Title'; } // Get property type name $propertyTypeName = 'Apartment'; if ($property->propertyType && $property->propertyType->texts && $property->propertyType->texts->count() > 0) { $propertyTypeName = $property->propertyType->texts->first()->name; } // Build address from relationships $addressParts = []; if ($property->area && $property->area->name) { $addressParts[] = $property->area->name; } if ($property->city && $property->city->name) { $addressParts[] = $property->city->name; } if ($property->state && $property->state->name) { $addressParts[] = $property->state->name; } if ($property->country && $property->country->name) { $addressParts[] = $property->country->name; } $propertyLocation = !empty($addressParts) ? implode(', ', $addressParts) : 'Location'; // Get area (use area_built or area_total) $propertyArea = $property->area_built ?? $property->area_total ?? 0; // Format area with commas $propertyArea = $propertyArea > 0 ? number_format($propertyArea, 0, '.', ',') : 0; // Build property URL to detail page $propertyUrl = route('property.show', $property->id); @endphp @endforeach @else {{-- Default placeholder properties if none provided --}} @for($i = 0; $i < 3; $i++) @endfor @endif