diff --git a/bootstrap/app.php b/bootstrap/app.php index 62d3729..f19ea8e 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,11 +3,13 @@ use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; +use Illuminate\Http\Request; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: [__DIR__ . '/../routes/web.php', __DIR__ . '/../routes/auth.php', + __DIR__ . '/../routes/admin.php', ], commands: __DIR__.'/../routes/console.php', @@ -15,8 +17,24 @@ return Application::configure(basePath: dirname(__DIR__)) ) ->withMiddleware(function (Middleware $middleware): void { - $middleware->redirectGuestsTo(fn(Illuminate\Http\Request $request) => route('auth.login.index')); - $middleware->redirectUsersTo(fn(Illuminate\Http\Request $request) => route('index')); + $middleware->redirectGuestsTo(function (Request $request) { + + if ($request->routeIs('admin.*')) { + return route('admin.auth.login.index'); + } + + return route('auth.login.index'); + }); + + $middleware->redirectUsersTo(function (Request $request) { + + if ($request->routeIs('admin.*')) { + return route('admin.dashboard.index'); + } + + return route('index'); + }); + }) ->withExceptions(function (Exceptions $exceptions): void { // diff --git a/config/auth.php b/config/auth.php index 3a06e62..0531989 100644 --- a/config/auth.php +++ b/config/auth.php @@ -42,6 +42,10 @@ return [ 'driver' => 'session', 'provider' => 'users', ], + 'admin' => [ + 'driver' => 'session', + 'provider' => 'admins', + ], ], /* @@ -66,6 +70,10 @@ return [ 'driver' => 'eloquent', 'model' => User::class, ], + 'admins' => [ + 'driver' => 'eloquent', + 'model' => \App\Models\Admin::class, + ], // 'users' => [ // 'driver' => 'database', diff --git a/resources/views/show-layouts/sidebar.blade.php b/resources/views/show-layouts/sidebar.blade.php index 8f4de99..0dd3647 100644 --- a/resources/views/show-layouts/sidebar.blade.php +++ b/resources/views/show-layouts/sidebar.blade.php @@ -15,21 +15,14 @@ - @if($type === 'tour') -