check()) { return redirect()->guest(route('login')) ->with('error', 'Log eerst in met je beheerder-account om toegang te krijgen tot het admin gedeelte.'); } if (! auth()->user()->isAdmin()) { return redirect()->route('home') ->with('error', 'Je hebt geen beheerderstoegang tot deze pagina.'); } // Auto-migrate check: Ensure that new database tables (like communications) are migrated // automatically when an admin enters the admin panel, avoiding 500 errors on Coolify/production. DatabaseSchemaHelper::ensureCommunicationsTables(); return $next($request); } }