Fix 500 error on admin access: make navigation layout resilient and auto-run pending migrations on admin entry

This commit is contained in:
2026-11-02 10:38:22 +01:00
parent 44c440222a
commit cf55f3c9f9
7 changed files with 76 additions and 9 deletions
+25 -4
View File
@@ -51,7 +51,14 @@
</a>
@php
$draftBadgeCount = \App\Models\Product::where('status', 'draft')->count();
$draftBadgeCount = 0;
try {
if (\Illuminate\Support\Facades\Schema::hasTable('products')) {
$draftBadgeCount = \App\Models\Product::where('status', 'draft')->count();
}
} catch (\Throwable $e) {
$draftBadgeCount = 0;
}
@endphp
<a href="{{ route('admin.makerworld.staging') }}" class="px-3 py-1.5 rounded-lg transition flex items-center space-x-1.5 {{ request()->routeIs('admin.makerworld.staging*') ? 'bg-slate-900 text-white font-semibold' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100' }}">
<i data-lucide="layers" class="w-3.5 h-3.5"></i>
@@ -74,7 +81,14 @@
</a>
@php
$unreadCommCount = \App\Models\Communication::where('status', 'new')->count();
$unreadCommCount = 0;
try {
if (\Illuminate\Support\Facades\Schema::hasTable('communications')) {
$unreadCommCount = \App\Models\Communication::where('status', 'new')->count();
}
} catch (\Throwable $e) {
$unreadCommCount = 0;
}
@endphp
<a href="{{ route('admin.communications.index') }}" class="px-3 py-1.5 rounded-lg transition flex items-center space-x-1.5 {{ request()->routeIs('admin.communications.*') ? 'bg-slate-900 text-white font-semibold' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100' }}">
<i data-lucide="message-square" class="w-3.5 h-3.5"></i>
@@ -101,7 +115,14 @@
<!-- Right Actions -->
<div class="flex items-center space-x-2.5">
@php
$isShopOffline = \App\Models\Setting::get('shop_offline', '0') === '1';
$isShopOffline = false;
try {
if (\Illuminate\Support\Facades\Schema::hasTable('settings')) {
$isShopOffline = \App\Models\Setting::get('shop_offline', '0') === '1';
}
} catch (\Throwable $e) {
$isShopOffline = false;
}
@endphp
<!-- Webshop Offline / Online Status Switcher -->
@@ -175,7 +196,7 @@
</header>
<!-- Offline Alert Banner -->
@if($isShopOffline ?? (\App\Models\Setting::get('shop_offline', '0') === '1'))
@if(!empty($isShopOffline))
<div class="bg-rose-500 text-white px-4 py-2.5 text-xs font-medium border-b border-rose-600 shadow-sm flex flex-col sm:flex-row items-center justify-between gap-3 sticky top-16 z-20">
<div class="flex items-center space-x-2">
<span class="w-2 h-2 rounded-full bg-white animate-pulse shrink-0"></span>