@php $activeType = $activeType ?? null; $filters = $filters ?? []; $search = trim((string) data_get($filters, 'search', '')); $location = trim((string) data_get($filters, 'location', '')); $filterQuery = array_filter([ 'search' => $search, 'location' => $location, ], fn ($value) => $value !== ''); $listingPaginator = $listings ?? collect(); $listingCollection = collect(method_exists($listingPaginator, 'items') ? $listingPaginator->items() : $listingPaginator); $savedListingKeyLookup = collect($savedListingKeys ?? [])->flip(); $typeLabels = [ 'job' => 'Jobs', 'rent' => 'Rentals', 'hostel' => 'Hostels', 'service' => 'Services', ]; $typeChipLabels = [ 'job' => 'Job', 'rent' => 'Rental', 'hostel' => 'Hostel', 'service' => 'Service', ]; $typeRouteKeys = [ 'job' => 'jobs', 'rent' => 'rentals', 'hostel' => 'hostels', 'service' => 'services', ]; $activeTypeRoute = $activeType ? ['type' => ($typeRouteKeys[$activeType] ?? $activeType)] : []; $pageLabel = $activeType ? ($typeLabels[$activeType] ?? 'Listings') : 'Explore'; $pageTitle = $activeType ? ($typeLabels[$activeType] ?? 'Listings') : 'Explore active listings'; $pageCopy = $activeType ? 'Browse approved and currently visible '.strtolower($pageLabel).' from Fily providers.' : 'Currently visible jobs, rentals, hostels, and services from Fily providers.'; $activeFilterText = collect([ $search ? 'matching "'.$search.'"' : null, $location ? 'near "'.$location.'"' : null, ])->filter()->implode(' '); $heroImages = [ 'job' => 'https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1600&q=80', 'rent' => 'https://images.unsplash.com/photo-1497366811353-6870744d04b2?auto=format&fit=crop&w=1600&q=80', 'hostel' => 'https://images.unsplash.com/photo-1555854877-bab0e564b8d5?auto=format&fit=crop&w=1600&q=80', 'service' => 'https://images.unsplash.com/photo-1581578731548-c64695cc6952?auto=format&fit=crop&w=1600&q=80', 'all' => 'https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1600&q=80', ]; $fallbackImages = [ 'job' => 'https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=900&q=80', 'rent' => 'https://images.unsplash.com/photo-1497366811353-6870744d04b2?auto=format&fit=crop&w=900&q=80', 'hostel' => 'https://images.unsplash.com/photo-1555854877-bab0e564b8d5?auto=format&fit=crop&w=900&q=80', 'service' => 'https://images.unsplash.com/photo-1581578731548-c64695cc6952?auto=format&fit=crop&w=900&q=80', ]; $categoryLinks = [ 'all' => ['Explore', route('frontend.category-list', $filterQuery), 'travel_explore'], 'job' => ['Jobs', route('frontend.category-list', array_merge(['type' => 'jobs'], $filterQuery)), 'work'], 'rent' => ['Rentals', route('frontend.category-list', array_merge(['type' => 'rentals'], $filterQuery)), 'apartment'], 'hostel' => ['Hostels', route('frontend.category-list', array_merge(['type' => 'hostels'], $filterQuery)), 'bed'], 'service' => ['Services', route('frontend.category-list', array_merge(['type' => 'services'], $filterQuery)), 'design_services'], ]; $listingPrice = function ($listing): string { if ($listing->listing_type === 'job') { return $listing->price ? 'Rs. '.number_format((float) $listing->price).'/mo' : 'Hiring'; } if ($listing->listing_type === 'service') { return $listing->price ? 'Starts Rs. '.number_format((float) $listing->price) : 'On request'; } return $listing->price ? 'Rs. '.number_format((float) $listing->price).'/mo' : 'On request'; }; $listingImage = function ($listing) use ($fallbackImages): string { return $listing->media_path ? asset('storage/'.$listing->media_path) : ($fallbackImages[$listing->listing_type] ?? $fallbackImages['rent']); }; $listingSpecs = function ($listing): array { $specs = collect(); if ($listing->listing_type === 'job') { $specs = $specs->merge([ ['work', $listing->meta_one], ['badge', $listing->meta_two], ['schedule', $listing->meta_three], ]); } elseif ($listing->listing_type === 'rent') { $roomDetails = is_string($listing->meta_three) ? json_decode($listing->meta_three, true) : null; $bedrooms = data_get($roomDetails, 'bedrooms'); $bathrooms = data_get($roomDetails, 'bathrooms'); $specs = $specs->merge([ ['home', $listing->meta_one], ['bed', $bedrooms ? $bedrooms.' '.Str::plural('Bed', (int) $bedrooms) : null], ['bathtub', $bathrooms ? $bathrooms.' '.Str::plural('Bath', (int) $bathrooms) : null], ]); } elseif ($listing->listing_type === 'hostel') { $specs = $specs->merge([ ['bed', $listing->meta_one], ['restaurant', $listing->meta_two ? 'Meals' : null], ['wifi', $listing->meta_three ? 'WiFi' : null], ]); } elseif ($listing->listing_type === 'service') { $specs = $specs->merge([ ['workspace_premium', is_numeric($listing->meta_one) ? $listing->meta_one.' '.Str::plural('Year', (int) $listing->meta_one) : null], ['location_searching', is_numeric($listing->meta_two) ? $listing->meta_two.' km' : null], ['payments', $listing->meta_three], ]); } return $specs->filter(fn ($item) => filled($item[1] ?? null))->take(3)->values()->all(); }; $listingDetails = function ($listing) use ($listingSpecs): string { return collect([$listing->location, $listing->city]) ->merge(collect($listingSpecs($listing))->pluck(1)) ->filter() ->take(4) ->implode(' - ') ?: 'Details available on request'; }; @endphp @include('frontend.partials.head', ['title' => 'Fily | '.$pageLabel]) @include('frontend.partials.header')

{{ $pageTitle }}

{{ $pageCopy }}

@if ($search !== '' || $location !== '') Clear @endif

Showing admin-approved listings that providers have kept visible{{ $activeFilterText ? ' '.$activeFilterText : '' }}.

travel_explore Explore all
@forelse ($listingCollection as $listing) @php $isSaved = $savedListingKeyLookup->has($listing->listing_type.':'.$listing->id); $detailsUrl = route('frontend.details', ['type' => $listing->listing_type, 'id' => $listing->id]); @endphp
{{ $listing->title }} {{ $typeChipLabels[$listing->listing_type] ?? ucfirst((string) $listing->listing_type) }}
@csrf

{{ $listing->title }}

{{ $listingPrice($listing) }}

location_on {{ collect([$listing->location, $listing->city])->filter()->implode(', ') ?: 'Location on request' }}

@forelse ($listingSpecs($listing) as [$icon, $value]) {{ $icon }}{{ $value }} @empty infoDetails on request @endforelse
{{ $listingDetails($listing) }} View Details
@empty
inventory_2

No active listings found

Approved and visible listings will appear here automatically.

@endforelse
@if (method_exists($listingPaginator, 'links') && $listingPaginator->hasPages())
{{ $listingPaginator->links() }}
@endif
@include('frontend.partials.footer')