<?php

// Manually clear Laravel caches
$cacheDir = __DIR__ . '/../bootstrap/cache';
$files = [
    $cacheDir . '/config.php',
    $cacheDir . '/routes-v7.php',
    $cacheDir . '/services.php',
    $cacheDir . '/packages.php',
];

echo "<h3>Clearing Bootstrap Cache:</h3>";
foreach ($files as $file) {
    if (file_exists($file)) {
        if (unlink($file)) {
            echo "Deleted: " . basename($file) . "<br>";
        } else {
            echo "Failed to delete: " . basename($file) . "<br>";
        }
    } else {
        echo "Not found: " . basename($file) . "<br>";
    }
}

// Clear compiled views
$viewDir = __DIR__ . '/../storage/framework/views';
echo "<h3>Clearing Compiled Views:</h3>";
if (is_dir($viewDir)) {
    $views = glob($viewDir . '/*.php');
    foreach ($views as $view) {
        if (unlink($view)) {
            echo "Deleted view: " . basename($view) . "<br>";
        }
    }
}
echo "Done!";
