fixed the explore page after the admin panel

This commit is contained in:
Ghassan Yusuf 2026-01-26 01:02:24 +03:00
parent b16351c416
commit 9b3b0cd1f0
3 changed files with 37 additions and 8 deletions

View File

@ -51,12 +51,14 @@ class ClubController extends Controller
'club_name' => $club->club_name,
'slug' => $club->slug,
'logo' => $club->logo,
'cover_image' => $club->cover_image,
'gps_lat' => (float) $club->gps_lat,
'gps_long' => (float) $club->gps_long,
'distance' => round($distance, 2), // distance in kilometers
'owner_name' => $club->owner ? $club->owner->full_name : 'N/A',
'owner_email' => $club->owner ? $club->owner->email : null,
'owner_mobile' => $club->owner ? $club->owner->mobile : null,
'address' => $club->address,
];
});
@ -133,10 +135,12 @@ class ClubController extends Controller
'club_name' => $club->club_name,
'slug' => $club->slug,
'logo' => $club->logo,
'cover_image' => $club->cover_image,
'gps_lat' => $club->gps_lat ? (float) $club->gps_lat : null,
'gps_long' => $club->gps_long ? (float) $club->gps_long : null,
'distance' => $distance !== null ? round($distance, 2) : null,
'owner_name' => $club->owner ? $club->owner->full_name : 'N/A',
'address' => $club->address,
];
});
@ -175,10 +179,12 @@ class ClubController extends Controller
'club_name' => $club->club_name,
'slug' => $club->slug,
'logo' => $club->logo,
'cover_image' => $club->cover_image,
'gps_lat' => $club->gps_lat ? (float) $club->gps_lat : null,
'gps_long' => $club->gps_long ? (float) $club->gps_long : null,
'distance' => null,
'owner_name' => $club->owner ? $club->owner->full_name : 'N/A',
'address' => $club->address,
];
});

View File

@ -249,14 +249,14 @@ document.addEventListener('DOMContentLoaded', function() {
if (!navigator.geolocation) {
showAlert('Geolocation is not supported by your browser', 'danger');
document.getElementById('loadingSpinner').style.display = 'none';
// If no geolocation, fetch all clubs
fetchAllClubs();
} else {
// Automatically start watching user's location
// This will fetch clubs once location is detected
startWatchingLocation();
}
// Initial load: fetch all clubs since 'all' is default
fetchAllClubs();
// Category buttons
document.querySelectorAll('.category-btn').forEach(btn => {
btn.addEventListener('click', function() {
@ -331,8 +331,8 @@ function startWatchingLocation() {
updateLocationDisplay(userLocation.latitude, userLocation.longitude);
// Fetch nearby clubs
fetchNearbyClubs(userLocation.latitude, userLocation.longitude);
// Fetch all clubs with location-based sorting (since 'all' is default)
fetchAllClubs();
// Stop watching after first successful location
if (watchId) {
@ -497,16 +497,37 @@ function displayClubs(clubs) {
clubs.forEach(club => {
const card = document.createElement('div');
card.className = 'col';
// Prepare cover image
let coverImageHtml = '';
if (club.cover_image) {
coverImageHtml = `<img src="/storage/${club.cover_image}" alt="${club.club_name}" loading="lazy" class="w-100 h-100 club-cover-img" style="object-fit: cover; transition: transform 0.3s ease;">`;
} else {
coverImageHtml = `<div class="w-100 h-100 d-flex align-items-center justify-content-center" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
<i class="bi bi-image text-white" style="font-size: 3rem; opacity: 0.3;"></i>
</div>`;
}
// Prepare logo
let logoHtml = '';
if (club.logo) {
logoHtml = `<img src="/storage/${club.logo}" alt="${club.club_name} logo" loading="lazy" class="w-100 h-100 rounded-circle" style="object-fit: contain;">`;
} else {
logoHtml = `<div class="w-100 h-100 rounded-circle bg-primary d-flex align-items-center justify-content-center">
<span class="text-white fw-bold fs-4">${club.club_name.charAt(0)}</span>
</div>`;
}
card.innerHTML = `
<div class="card border shadow-sm overflow-hidden club-card" style="border-radius: 0; cursor: pointer; transition: all 0.3s ease;">
<!-- Cover Image -->
<div class="position-relative overflow-hidden" style="height: 192px;">
<img src="https://via.placeholder.com/400x200?text=${encodeURIComponent(club.club_name)}" alt="${club.club_name}" loading="lazy" class="w-100 h-100 club-cover-img" style="object-fit: cover; transition: transform 0.3s ease;">
${coverImageHtml}
<!-- Club Logo - Bottom Left -->
<div class="position-absolute" style="bottom: 8px; left: 8px;">
<div class="bg-white shadow border p-0.5" style="width: 80px; height: 80px; border-radius: 50%; border-color: rgba(0,0,0,0.1) !important;">
<img src="https://via.placeholder.com/80x80?text=Logo" alt="${club.club_name} logo" loading="lazy" class="w-100 h-100 rounded-circle" style="object-fit: contain;">
${logoHtml}
</div>
</div>

View File

@ -82,7 +82,9 @@ Route::middleware(['auth'])->group(function () {
// Platform Admin routes (Super Admin only)
Route::middleware(['auth', 'verified', 'role:super-admin'])->prefix('admin')->name('admin.')->group(function () {
Route::get('/', [App\Http\Controllers\Admin\PlatformController::class, 'index'])->name('platform.index');
Route::get('/', function () {
return redirect()->route('admin.platform.clubs');
})->name('platform.index');
// All Clubs Management
Route::get('/clubs', [App\Http\Controllers\Admin\PlatformController::class, 'clubs'])->name('platform.clubs');