/** * IMPORTANT — Laravel 10 fresh installs (created via `laravel new` or * `composer create-project laravel/laravel`) use the classic structure with * app/Http/Kernel.php, NOT bootstrap/app.php (that's the Laravel 11+ style). * * Since your `jandkhomes` project was created as a standard Laravel 10 app, * you almost certainly have app/Http/Kernel.php. Open that file and add the * two lines below to the $routeMiddleware array (Laravel 10.x) — it may be * named $middlewareAliases on the very latest 10.x point releases: */ protected $middlewareAliases = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, // --- Added for the admin panel (Step 3) --- 'admin.auth' => \App\Http\Middleware\AdminAuthenticate::class, 'admin.guest' => \App\Http\Middleware\AdminGuest::class, ]; /** * Everything above except the last two lines is what a stock Laravel 10 * Kernel.php already contains — only add the 'admin.auth' and 'admin.guest' * lines to whatever list you already have. Don't replace the whole array if * you've customized it elsewhere. * * If your project genuinely uses the newer bootstrap/app.php style instead * (rare for a plain Laravel 10 install, but happens if it was scaffolded * from a Laravel 11 template and downgraded), use this shape instead: * * ->withMiddleware(function (Middleware $middleware) { * $middleware->alias([ * 'admin.auth' => \App\Http\Middleware\AdminAuthenticate::class, * 'admin.guest' => \App\Http\Middleware\AdminGuest::class, * ]); * }) * * Run `php artisan route:list` after saving — if it doesn't error, the * alias registered correctly either way. */