Script erstellt
This commit is contained in:
291
fix-admin-layout.php
Normal file
291
fix-admin-layout.php
Normal file
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
// Fix: Admin-Layout korrigieren
|
||||
echo "👑 Fix: Admin-Layout korrigieren\n";
|
||||
echo "==============================\n\n";
|
||||
|
||||
// 1. Layout-Datei korrigieren
|
||||
echo "1. 🎨 Layout-Datei korrigieren...\n";
|
||||
|
||||
$layoutContent = '<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<title>@yield("title", "NeoNail Datenbank")</title>
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background: rgba(255, 255, 255, 0.95) !important;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(45deg, #667eea, #764ba2);
|
||||
border: none;
|
||||
border-radius: 25px;
|
||||
padding: 10px 25px;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: linear-gradient(45deg, #5a6fd8, #6a4190);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.nail-polish-card {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.nail-polish-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.nail-polish-image {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
object-fit: cover;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
border-radius: 25px;
|
||||
border: 2px solid #e9ecef;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.search-box:focus {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Dropdown-Menüs über alle anderen Elemente legen */
|
||||
.dropdown-menu {
|
||||
z-index: 9999 !important;
|
||||
position: absolute !important;
|
||||
}
|
||||
|
||||
/* Navbar hat höheren z-index */
|
||||
.navbar {
|
||||
z-index: 1000 !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Dropdown-Container */
|
||||
.dropdown {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Sicherstellen, dass Dropdowns über Cards angezeigt werden */
|
||||
.navbar-nav .dropdown-menu {
|
||||
z-index: 9999 !important;
|
||||
position: absolute !important;
|
||||
top: 100% !important;
|
||||
left: 0 !important;
|
||||
float: none !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@yield("styles")
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-bold" href="{{ route("user-nail-polishes.index") }}">
|
||||
<i class="fas fa-palette me-2"></i>NeoNail DB
|
||||
</a>
|
||||
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto">
|
||||
@auth
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route("user-nail-polishes.index") }}">
|
||||
<i class="fas fa-home me-1"></i>Meine Sammlung
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route("user-nail-polishes.available") }}">
|
||||
<i class="fas fa-plus me-1"></i>Verfügbare Lacke
|
||||
</a>
|
||||
</li>
|
||||
@if(auth()->user()->isAdmin())
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-cog me-1"></i>Admin
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="{{ route("admin.dashboard") }}">Dashboard</a></li>
|
||||
<li><a class="dropdown-item" href="{{ route("admin.users.index") }}">Benutzer</a></li>
|
||||
<li><a class="dropdown-item" href="{{ route("nail-polishes.index") }}">Nagellacke</a></li>
|
||||
<li><a class="dropdown-item" href="{{ route("admin.statistics") }}">Statistiken</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
@endauth
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav">
|
||||
@guest
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route("login") }}">Anmelden</a>
|
||||
</li>
|
||||
@else
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-user me-1"></i>{{ Auth::user()->name }}
|
||||
@if(auth()->user()->isAdmin())
|
||||
<span class="badge bg-primary ms-1">Admin</span>
|
||||
@endif
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ route("logout") }}"
|
||||
onclick="event.preventDefault(); document.getElementById("logout-form").submit();">
|
||||
<i class="fas fa-sign-out-alt me-1"></i>Abmelden
|
||||
</a>
|
||||
<form id="logout-form" action="https://neonail.vogt.de.com/logout" method="POST" class="d-none">
|
||||
@csrf
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@endguest
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="py-4">
|
||||
<div class="container">
|
||||
@if(session("success"))
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<i class="fas fa-check-circle me-2"></i>{{ session("success") }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(session("error"))
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<i class="fas fa-exclamation-circle me-2"></i>{{ session("error") }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@yield("content")
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
@yield("scripts")
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
file_put_contents('resources/views/layouts/app.blade.php', $layoutContent);
|
||||
echo " ✅ Layout-Datei korrigiert\n";
|
||||
|
||||
// 2. User Model prüfen und korrigieren
|
||||
echo "2. 📋 User Model prüfen...\n";
|
||||
$userModelPath = 'app/Models/User.php';
|
||||
if (file_exists($userModelPath)) {
|
||||
$content = file_get_contents($userModelPath);
|
||||
|
||||
// Prüfe ob isAdmin Methode korrekt ist
|
||||
if (strpos($content, 'public function isAdmin()') !== false) {
|
||||
echo " ✅ isAdmin() Methode vorhanden\n";
|
||||
|
||||
// Prüfe ob die Methode korrekt implementiert ist
|
||||
if (strpos($content, '$this->is_admin || in_array($this->email') !== false) {
|
||||
echo " ✅ isAdmin() Methode korrekt implementiert\n";
|
||||
} else {
|
||||
echo " ⚠️ isAdmin() Methode könnte inkorrekt sein\n";
|
||||
}
|
||||
} else {
|
||||
echo " ❌ isAdmin() Methode fehlt\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo " ❌ User Model nicht gefunden\n";
|
||||
}
|
||||
|
||||
// 3. Cache leeren
|
||||
echo "3. 🧹 Cache leeren...\n";
|
||||
system('php artisan cache:clear 2>/dev/null || echo " ⚠️ cache:clear übersprungen"');
|
||||
system('php artisan config:clear 2>/dev/null || echo " ⚠️ config:clear übersprungen"');
|
||||
system('php artisan view:clear 2>/dev/null || echo " ⚠️ view:clear übersprungen"');
|
||||
system('php artisan route:clear 2>/dev/null || echo " ⚠️ route:clear übersprungen"');
|
||||
echo " ✅ Cache geleert\n";
|
||||
|
||||
// 4. Admin-User Status prüfen
|
||||
echo "4. 👑 Admin-User Status prüfen...\n";
|
||||
try {
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
// Laravel Bootstrap
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
|
||||
|
||||
// Alle User prüfen
|
||||
$users = \App\Models\User::all();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$isAdmin = $user->isAdmin();
|
||||
$isAdminColumn = $user->is_admin;
|
||||
$email = $user->email;
|
||||
|
||||
echo " 📧 $email:\n";
|
||||
echo " - is_admin Spalte: " . ($isAdminColumn ? 'Ja' : 'Nein') . "\n";
|
||||
echo " - isAdmin() Methode: " . ($isAdmin ? 'Ja' : 'Nein') . "\n";
|
||||
|
||||
if ($isAdminColumn && !$isAdmin) {
|
||||
echo " ⚠️ WARNUNG: Spalte ist true, aber Methode gibt false zurück!\n";
|
||||
} elseif (!$isAdminColumn && $isAdmin) {
|
||||
echo " ℹ️ INFO: Spalte ist false, aber Methode gibt true zurück (Email-Check)\n";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo " ❌ Fehler beim Prüfen der User: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
echo "\n✅ Admin-Layout korrigiert!\n";
|
||||
echo "🔗 Testen Sie jetzt:\n";
|
||||
echo "1. Melden Sie sich als neuer Admin an\n";
|
||||
echo "2. Prüfen Sie ob Admin-Menü sichtbar ist\n";
|
||||
echo "3. Prüfen Sie ob Admin-Badge neben dem Namen steht\n";
|
||||
echo "4. Versuchen Sie auf /admin/users zuzugreifen\n";
|
||||
echo "5. Falls Problem besteht, führen Sie php fix-admin-view.php aus\n";
|
||||
?>
|
||||
Reference in New Issue
Block a user