#!/bin/bash

# Fix home page slider images on server
# Run this on your production server

echo "🔧 Fixing Home Page Slider Images..."
echo ""

cd "$(dirname "$0")" || exit 1

if [ ! -f "artisan" ]; then
    echo "❌ Error: Not in Laravel root directory"
    exit 1
fi

echo "1️⃣  Clearing all caches..."
php artisan view:clear
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan clear-compiled

echo ""
echo "2️⃣  Removing compiled views..."
rm -rf storage/framework/views/*.php

echo ""
echo "3️⃣  Verifying storage symlink..."
if [ -L "public/storage" ]; then
    echo "✅ Storage symlink exists"
    ls -la public/storage | head -1
else
    echo "⚠️  Creating storage symlink..."
    php artisan storage:link
fi

echo ""
echo "4️⃣  Setting permissions..."
chmod -R 775 storage bootstrap/cache

echo ""
echo "✅ Done! Now:"
echo "   1. Hard refresh browser: Ctrl+Shift+R"
echo "   2. Check homepage - images should use /storage/ URLs"
echo "   3. Verify: Images should match admin panel URLs"

