From d5b7336de2de2f537ab9f1a79526456350284aa7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Oct 2023 20:15:17 +0700 Subject: [PATCH] Update: RedirectAuthController, Hak akses login redirect --- .../Auth/RedirectAuthController.php | 22 ++ app/Http/Controllers/HomeController.php | 2 + app/Providers/RouteServiceProvider.php | 2 +- resources/views/dashboard/index.blade.php | 39 +++- .../views/dashboard/peminjaman.blade.php | 194 +----------------- resources/views/layouts/main.blade.php | 2 + routes/web.php | 3 + 7 files changed, 69 insertions(+), 195 deletions(-) create mode 100644 app/Http/Controllers/Auth/RedirectAuthController.php diff --git a/app/Http/Controllers/Auth/RedirectAuthController.php b/app/Http/Controllers/Auth/RedirectAuthController.php new file mode 100644 index 0000000..cbe2cb5 --- /dev/null +++ b/app/Http/Controllers/Auth/RedirectAuthController.php @@ -0,0 +1,22 @@ +role_id == '1') { + // Admin + return redirect()->route('dashboard.home.admin'); + } elseif (Auth::check() && Auth::user()->role_id == 'user') { + return redirect()->route('dashboard.home.user'); + } else { + return redirect()->route('login'); + } + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 1cb5bc5..835d3b1 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,9 +3,11 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class HomeController extends Controller { + public function index() { $data = [ diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 025e874..41f7c97 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider * * @var string */ - public const HOME = '/dashboard'; + public const HOME = '/redirect'; /** * Define your route model bindings, pattern filters, and other route configuration. diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php index 8732072..61e1d9f 100644 --- a/resources/views/dashboard/index.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -115,9 +115,11 @@ + +
- +
@@ -165,4 +167,39 @@ + + @push('script') + {{-- --}} + @endpush @endsection diff --git a/resources/views/dashboard/peminjaman.blade.php b/resources/views/dashboard/peminjaman.blade.php index 449b156..c1ced36 100644 --- a/resources/views/dashboard/peminjaman.blade.php +++ b/resources/views/dashboard/peminjaman.blade.php @@ -1,193 +1 @@ -@extends('layouts.main') -@section('title', 'Peminjaman') -@section('content') -
- -
-
-
-
-
Data Peminjaman
-
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - @php - $no_peminjaman = 1; - @endphp - @foreach ($peminjaman as $data) - - - - - - - - - @endforeach - -
NoNama AssetTgl PeminjamanPJ KeluarAsal GudangAction
NoNama AssetTgl PeminjamanPJ KeluarAsal GudangAction
{{ $no_peminjaman++ }}{{ $data->asset->name }}{{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }}{{ $data->exit_pic }}{{ $data->warehouse->name }} - - - - {{-- - - --}} -
-
-
-
-
- - - - - - - @foreach ($peminjaman as $data) - - @endforeach -@endsection +{{-- diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index dd80dc3..fe1f407 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -85,6 +85,8 @@ + @stack('script') + @include('layouts.script') diff --git a/routes/web.php b/routes/web.php index 2e2de2e..f1eaf6b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -32,6 +32,9 @@ use App\Http\Controllers\SettingPlatformController; Route::redirect('/', '/login'); +Route::get('/redirect', [\App\Http\Controllers\Auth\RedirectAuthController::class, 'redirectAuth'])->name('redirect')->middleware('auth'); + + Route::middleware('auth')->group(function () { Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');