first commit
This commit is contained in:
@@ -0,0 +1,397 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title', $city->name . ', ' . $city->country)
|
||||
|
||||
@section('content')
|
||||
<!-- Hero Header -->
|
||||
<div class="relative bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 text-white overflow-hidden">
|
||||
@if($city->image_url)
|
||||
<img src="{{ $city->image_url }}" alt="{{ $city->name }}" class="absolute inset-0 w-full h-full object-cover">
|
||||
<div class="absolute inset-0 bg-black bg-opacity-40"></div>
|
||||
@elseif($city->thumbnail_url)
|
||||
<img src="{{ $city->thumbnail_url }}" alt="{{ $city->name }}" class="absolute inset-0 w-full h-full object-cover">
|
||||
<div class="absolute inset-0 bg-black bg-opacity-40"></div>
|
||||
@else
|
||||
<div class="absolute inset-0 opacity-10">
|
||||
<div class="absolute top-0 right-1/4 w-96 h-96 bg-white rounded-full mix-blend-overlay filter blur-3xl"></div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-5xl md:text-6xl font-bold mb-3 drop-shadow-lg">{{ $city->name }}</h1>
|
||||
<p class="text-2xl text-purple-100 mb-4 drop-shadow-md">{{ $city->country }}</p>
|
||||
|
||||
@if($city->wikipedia_url)
|
||||
<a href="{{ $city->wikipedia_url }}" target="_blank" class="inline-flex items-center px-6 py-3 bg-white text-purple-600 rounded-lg font-semibold hover:bg-purple-50 transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5">
|
||||
<span>View on Wikipedia</span>
|
||||
<svg class="w-5 h-5 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
|
||||
</svg>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
||||
<!-- City Summary -->
|
||||
@if($city->wikipedia_summary)
|
||||
<div class="bg-gradient-to-br from-white to-gray-50 rounded-2xl shadow-xl p-8 mb-12 border border-gray-100">
|
||||
<div class="flex items-center mb-6">
|
||||
<div class="w-1 h-8 bg-gradient-to-b from-purple-500 to-pink-500 rounded-full mr-4"></div>
|
||||
<h2 class="text-3xl font-bold text-gray-900">About {{ $city->name }}</h2>
|
||||
</div>
|
||||
<p class="text-gray-700 text-lg leading-relaxed">{{ $city->wikipedia_summary }}</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
||||
<!-- Map -->
|
||||
<div class="lg:col-span-2">
|
||||
<div class="bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-100">
|
||||
<div class="px-6 py-5 bg-gradient-to-r from-purple-50 to-pink-50 border-b border-gray-200">
|
||||
<div class="flex items-center">
|
||||
<div class="w-1 h-6 bg-gradient-to-b from-purple-500 to-pink-500 rounded-full mr-3"></div>
|
||||
<h2 class="text-2xl font-bold text-gray-900">Map & Attractions</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
x-data="cityMap({{ $city->latitude }}, {{ $city->longitude }}, '{{ $city->slug }}')"
|
||||
x-init="initMap()"
|
||||
id="map"
|
||||
class="h-[500px]"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Attractions List -->
|
||||
<div class="lg:col-span-1">
|
||||
<div class="bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-100">
|
||||
<div class="px-6 py-5 bg-gradient-to-r from-indigo-50 to-purple-50 border-b border-gray-200">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<div class="w-1 h-6 bg-gradient-to-b from-indigo-500 to-purple-500 rounded-full mr-3"></div>
|
||||
<h2 class="text-2xl font-bold text-gray-900">Attractions</h2>
|
||||
</div>
|
||||
<span class="px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm font-semibold">{{ $city->attractions->count() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div x-data="attractionsList('{{ $city->slug }}')" x-init="loadAttractions()">
|
||||
<!-- Category Filter -->
|
||||
<div class="p-5 border-b border-gray-200 bg-gray-50">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-2">Filter by Category</label>
|
||||
<select
|
||||
x-model="selectedCategory"
|
||||
@change="filterAttractions()"
|
||||
:disabled="loading"
|
||||
class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed transition-all duration-200"
|
||||
>
|
||||
<option value="">All Categories</option>
|
||||
<option value="museum">Museums</option>
|
||||
<option value="restaurant">Restaurants</option>
|
||||
<option value="historic">Historic</option>
|
||||
<option value="park">Parks</option>
|
||||
<option value="cultural">Cultural</option>
|
||||
<option value="entertainment">Entertainment</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Attractions List -->
|
||||
<div class="divide-y divide-gray-100 max-h-[500px] overflow-y-auto">
|
||||
<template x-for="attraction in filteredAttractions" :key="attraction.id">
|
||||
<div class="p-5 hover:bg-gradient-to-r hover:from-purple-50 hover:to-pink-50 cursor-pointer transition-all duration-200 group" @click="highlightAttraction(attraction)">
|
||||
<h3 class="font-bold text-gray-900 group-hover:text-purple-600 transition-colors duration-200" x-text="attraction.name"></h3>
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-gray-100 text-gray-700 capitalize" x-text="attraction.category"></span>
|
||||
<template x-if="attraction.rating">
|
||||
<span class="inline-flex items-center text-sm font-semibold text-yellow-600">
|
||||
★ <span x-text="attraction.rating" class="ml-0.5"></span>
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div x-show="loading" class="p-12 text-center">
|
||||
<div class="inline-flex flex-col items-center gap-3">
|
||||
<svg class="animate-spin h-8 w-8 text-purple-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
<span class="text-gray-600 font-medium">Loading attractions...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div x-show="!loading && filteredAttractions.length === 0" class="p-12 text-center text-gray-500">
|
||||
<div class="inline-flex items-center justify-center w-16 h-16 bg-gray-100 rounded-full mb-4">
|
||||
<svg class="h-8 w-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<p class="font-semibold text-gray-700 mb-1">No attractions found</p>
|
||||
<p class="text-sm">Try selecting a different category</p>
|
||||
</div>
|
||||
|
||||
<!-- Pagination Controls -->
|
||||
<div x-show="!loading && pagination.last_page > 1" class="p-5 border-t border-gray-200 bg-gradient-to-r from-gray-50 to-purple-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<button
|
||||
@click="loadPage(pagination.current_page - 1)"
|
||||
:disabled="pagination.current_page === 1"
|
||||
class="px-4 py-2 text-sm font-semibold border-2 border-purple-200 text-purple-600 rounded-lg hover:bg-purple-50 hover:border-purple-300 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200"
|
||||
>
|
||||
Previous
|
||||
</button>
|
||||
<span class="text-sm font-semibold text-gray-700">
|
||||
Page <span x-text="pagination.current_page" class="text-purple-600"></span> of <span x-text="pagination.last_page" class="text-purple-600"></span>
|
||||
</span>
|
||||
<button
|
||||
@click="loadPage(pagination.current_page + 1)"
|
||||
:disabled="pagination.current_page === pagination.last_page"
|
||||
class="px-4 py-2 text-sm font-semibold border-2 border-purple-200 text-purple-600 rounded-lg hover:bg-purple-50 hover:border-purple-300 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
function cityMap(lat, lon, citySlug) {
|
||||
return {
|
||||
map: null,
|
||||
markers: [],
|
||||
allAttractions: [],
|
||||
selectedCategory: '',
|
||||
|
||||
// Define colors and icons for each category
|
||||
categoryColors: {
|
||||
museum: '#8B4513', // Brown
|
||||
restaurant: '#FF6347', // Tomato
|
||||
historic: '#4169E1', // Royal Blue
|
||||
park: '#228B22', // Forest Green
|
||||
cultural: '#9370DB', // Medium Purple
|
||||
entertainment: '#FF1493', // Deep Pink
|
||||
other: '#808080' // Gray
|
||||
},
|
||||
|
||||
categoryIcons: {
|
||||
museum: '🏛️', // Museum emoji
|
||||
restaurant: '🍽️', // Restaurant emoji
|
||||
historic: '🏰', // Castle emoji
|
||||
park: '🌳', // Tree emoji
|
||||
cultural: '🎭', // Theater emoji
|
||||
entertainment: '🎪', // Circus tent emoji
|
||||
other: '📍' // Pin emoji
|
||||
},
|
||||
|
||||
initMap() {
|
||||
// Initialize Leaflet map
|
||||
this.map = L.map('map').setView([lat, lon], 13);
|
||||
|
||||
// Add OpenStreetMap tiles
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
}).addTo(this.map);
|
||||
|
||||
// Add city marker (star icon for the city)
|
||||
const cityIcon = L.divIcon({
|
||||
html: '<div style="font-size: 24px;">⭐</div>',
|
||||
className: 'city-marker',
|
||||
iconSize: [24, 24],
|
||||
iconAnchor: [12, 12]
|
||||
});
|
||||
|
||||
L.marker([lat, lon], { icon: cityIcon })
|
||||
.addTo(this.map)
|
||||
.bindPopup('<b>{{ $city->name }}</b>')
|
||||
.openPopup();
|
||||
|
||||
// Load and display attractions
|
||||
this.loadAttractions();
|
||||
|
||||
// Listen for category filter events
|
||||
window.addEventListener('filter-category', (e) => {
|
||||
this.filterAttractions(e.detail.category);
|
||||
});
|
||||
|
||||
// Listen for highlight attraction events from the list
|
||||
window.addEventListener('highlight-attraction', (e) => {
|
||||
const attraction = e.detail.attraction;
|
||||
// Find the corresponding marker
|
||||
const marker = this.markers.find(m =>
|
||||
Math.abs(m.getLatLng().lat - attraction.latitude) < 0.0001 &&
|
||||
Math.abs(m.getLatLng().lng - attraction.longitude) < 0.0001
|
||||
);
|
||||
if (marker) {
|
||||
this.map.setView([attraction.latitude, attraction.longitude], 16);
|
||||
marker.openPopup();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
createMarkerIcon(category) {
|
||||
const icon = this.categoryIcons[category] || this.categoryIcons.other;
|
||||
const color = this.categoryColors[category] || this.categoryColors.other;
|
||||
return L.divIcon({
|
||||
html: `<div style="font-size: 20px; background-color: white; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border: 2px solid ${color}; box-shadow: 0 2px 6px rgba(0,0,0,0.3);">${icon}</div>`,
|
||||
className: '',
|
||||
iconSize: [28, 28],
|
||||
iconAnchor: [14, 14],
|
||||
popupAnchor: [0, -14]
|
||||
});
|
||||
},
|
||||
|
||||
async loadAttractions() {
|
||||
try {
|
||||
const response = await fetch(`/api/cities/${citySlug}/attractions?limit=100`);
|
||||
const data = await response.json();
|
||||
|
||||
// Handle both paginated and non-paginated responses
|
||||
this.allAttractions = data.data || data;
|
||||
|
||||
// Display all attractions on map
|
||||
this.displayAttractions(this.allAttractions);
|
||||
} catch (error) {
|
||||
console.error('Error loading attractions:', error);
|
||||
}
|
||||
},
|
||||
|
||||
displayAttractions(attractions) {
|
||||
// Clear existing markers
|
||||
this.markers.forEach(marker => this.map.removeLayer(marker));
|
||||
this.markers = [];
|
||||
|
||||
// Add new markers
|
||||
attractions.forEach(attraction => {
|
||||
const icon = this.createMarkerIcon(attraction.category);
|
||||
const marker = L.marker([attraction.latitude, attraction.longitude], { icon })
|
||||
.addTo(this.map)
|
||||
.bindPopup(`
|
||||
<div class="p-2">
|
||||
<b>${attraction.name}</b><br>
|
||||
<span class="text-sm capitalize" style="color: ${this.categoryColors[attraction.category] || this.categoryColors.other}">${attraction.category}</span>
|
||||
${attraction.rating ? `<br><span class="text-yellow-600">★ ${attraction.rating}</span>` : ''}
|
||||
</div>
|
||||
`);
|
||||
|
||||
// Store category with marker for filtering
|
||||
marker.category = attraction.category;
|
||||
this.markers.push(marker);
|
||||
});
|
||||
},
|
||||
|
||||
filterAttractions(category) {
|
||||
this.selectedCategory = category;
|
||||
|
||||
if (!category) {
|
||||
// Show all markers
|
||||
this.markers.forEach(marker => {
|
||||
if (!this.map.hasLayer(marker)) {
|
||||
marker.addTo(this.map);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Show only markers matching the category
|
||||
this.markers.forEach(marker => {
|
||||
if (marker.category === category) {
|
||||
if (!this.map.hasLayer(marker)) {
|
||||
marker.addTo(this.map);
|
||||
}
|
||||
} else {
|
||||
if (this.map.hasLayer(marker)) {
|
||||
this.map.removeLayer(marker);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function attractionsList(citySlug) {
|
||||
return {
|
||||
attractions: [],
|
||||
filteredAttractions: [],
|
||||
selectedCategory: '',
|
||||
loading: false,
|
||||
currentPage: 1,
|
||||
pagination: {
|
||||
current_page: 1,
|
||||
last_page: 1,
|
||||
per_page: 20,
|
||||
total: 0
|
||||
},
|
||||
|
||||
async loadAttractions(page = 1) {
|
||||
this.loading = true;
|
||||
|
||||
try {
|
||||
let url = `/api/cities/${citySlug}/attractions?page=${page}`;
|
||||
if (this.selectedCategory) {
|
||||
url += `&category=${this.selectedCategory}`;
|
||||
}
|
||||
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
// Handle paginated response
|
||||
if (data.data) {
|
||||
this.filteredAttractions = data.data;
|
||||
this.pagination = {
|
||||
current_page: data.current_page || 1,
|
||||
last_page: data.last_page || 1,
|
||||
per_page: data.per_page || 20,
|
||||
total: data.total || 0
|
||||
};
|
||||
} else {
|
||||
// Handle non-paginated response (fallback)
|
||||
this.filteredAttractions = data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading attractions:', error);
|
||||
this.filteredAttractions = [];
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async filterAttractions() {
|
||||
await this.loadAttractions(1);
|
||||
|
||||
// Notify the map to filter attractions
|
||||
window.dispatchEvent(new CustomEvent('filter-category', {
|
||||
detail: { category: this.selectedCategory }
|
||||
}));
|
||||
},
|
||||
|
||||
async loadPage(page) {
|
||||
if (page >= 1 && page <= this.pagination.last_page) {
|
||||
await this.loadAttractions(page);
|
||||
}
|
||||
},
|
||||
|
||||
highlightAttraction(attraction) {
|
||||
// Dispatch event to highlight marker on map
|
||||
window.dispatchEvent(new CustomEvent('highlight-attraction', {
|
||||
detail: { attraction }
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@endsection
|
||||
Reference in New Issue
Block a user