diff --git a/app/Helpers/CustomHelper.php b/app/Helpers/CustomHelper.php index 9673b8b..aab0549 100644 --- a/app/Helpers/CustomHelper.php +++ b/app/Helpers/CustomHelper.php @@ -1,4 +1,6 @@ role_id; + } + + switch($role) { + case '1': + return "Administrator"; + case '2': + return "Admin Monitoring"; + case '3': + return "Perusahaan"; + case '4': + return "Admin Konten"; + default: + return "Role Tidak Dikenal"; + } + } +} + +if (!function_exists('shorten_text')) { + function shorten_text($text, $maxLength = 100) { + if (strlen($text) > $maxLength) { + return substr($text, 0, $maxLength) . '...'; + } + + return $text; + } +} diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index c8c44ef..f37bce1 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -25,8 +25,7 @@ public function loginAction(LoginRequest $request){ if(Auth::attempt($validatedData)){ $request->session()->regenerate(); - // return redirect()->intended('/dashboard/overview'); - return "masuk"; + return redirect()->intended('/dashboard/overview'); }else{ return redirect()->back(); } diff --git a/app/Http/Controllers/Dashboard/OverviewController.php b/app/Http/Controllers/Dashboard/OverviewController.php new file mode 100644 index 0000000..fe86706 --- /dev/null +++ b/app/Http/Controllers/Dashboard/OverviewController.php @@ -0,0 +1,16 @@ + 'Ikhtisar', + 'page' => 'overview' + ]); + } +} diff --git a/app/Http/Middleware/AuthenticatedMiddleware.php b/app/Http/Middleware/AuthenticatedMiddleware.php new file mode 100644 index 0000000..3e9eaac --- /dev/null +++ b/app/Http/Middleware/AuthenticatedMiddleware.php @@ -0,0 +1,26 @@ +route('dashboard.overview'); + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/RoleMiddleware.php b/app/Http/Middleware/RoleMiddleware.php new file mode 100644 index 0000000..055e42d --- /dev/null +++ b/app/Http/Middleware/RoleMiddleware.php @@ -0,0 +1,29 @@ +route('login'); + } + + if (!in_array(Auth::user()->role_id, $roles)) { + return abort(403, 'Anda tidak memiliki akses ke halaman ini.'); + } + + return $next($request); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index b2425f8..813a384 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -47,4 +47,8 @@ protected function casts(): array 'password' => 'hashed', ]; } + + public function role(){ + return $this->belongsTo(Role::class, 'role_id', 'id'); + } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 7b162da..7a17a35 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,5 +1,8 @@ withMiddleware(function (Middleware $middleware) { - // + $middleware->alias([ + 'role' => RoleMiddleware::class, + 'authenticated' => AuthenticatedMiddleware::class + ]); }) ->withExceptions(function (Exceptions $exceptions) { // diff --git a/database/seeders/RoleSeeder.php b/database/seeders/RoleSeeder.php index 721f928..0edb7a2 100644 --- a/database/seeders/RoleSeeder.php +++ b/database/seeders/RoleSeeder.php @@ -15,9 +15,9 @@ public function run(): void { Role::insert([ ['name' => "Administrator", 'description' => null], - ['name' => "Monitoring Admin", 'description' => null], - ['name' => "Company", 'description' => null], - ['name' => "Content Admin", 'description' => null], + ['name' => "Admin Monitoring", 'description' => null], + ['name' => "Perusahaan", 'description' => null], + ['name' => "Admin Konten", 'description' => null], ]); } } diff --git a/public/assets/dashboard/css/custom.css b/public/assets/dashboard/css/custom.css index c72dbb2..85a05e0 100644 --- a/public/assets/dashboard/css/custom.css +++ b/public/assets/dashboard/css/custom.css @@ -10,6 +10,21 @@ .required-input{ font-size: 0.8rem; } +.active-page{ + color: #3572EF !important; + background-color: #ebeef2 !important; + font-family: "DM Sans", sans-serif; + font-weight: 700; + font-size: 15px; + letter-spacing: 0.01em; + text-transform: none; + line-height: 1.25rem; +} + +.active-page span{ + color: #3572EF !important; +} + #password-strength-status { margin-top: 5px; font-size: 12px; diff --git a/public/assets/dashboard/js/scripts.js b/public/assets/dashboard/js/scripts.js index 71b3b92..7cd3236 100644 --- a/public/assets/dashboard/js/scripts.js +++ b/public/assets/dashboard/js/scripts.js @@ -106,14 +106,14 @@ _self_link = self.attr('href'); if (fileName.match(_self_link)) { - self.closest("li").addClass('active current-page').parents().closest("li").addClass("active current-page"); + self.closest("li").addClass('').parents().closest("li").addClass(""); self.closest("li").children('.nk-menu-sub').css('display', 'block'); self.parents().closest("li").children('.nk-menu-sub').css('display', 'block'); } else { - self.closest("li").removeClass('active current-page').parents().closest("li:not(.current-page)").removeClass("active"); + self.closest("li").removeClass('').parents().closest("li:not(.current-page)").removeClass("active"); } }); - }; // PasswordSwitch @v1.0 + }; NioApp.PassSwitch = function () { diff --git a/resources/views/dashboard/overview/index.blade.php b/resources/views/dashboard/overview/index.blade.php new file mode 100644 index 0000000..fc9527e --- /dev/null +++ b/resources/views/dashboard/overview/index.blade.php @@ -0,0 +1,488 @@ +@include('partials.dashboard.head') +@include('partials.dashboard.sidebar') +@include('partials.dashboard.header') + +
+
+
+
+
+
+
+

Ikhtisar

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
Today Orders
+
+
+
+
+
1,945
+
+ +
+
+
4.63% vs. last week
+
+
+
+
+
+
+
+
+
+
+
+
Today Revenue
+
+
+
+
+
$2,338
+
+ +
+
+
2.34% vs. last week
+
+
+
+
+
+
+
+
+
+
+
+
Today Customers
+
+
+
+
+
847
+
+ +
+
+
4.63% vs. last week
+
+
+
+
+
+
+
+
+
+
+
+
Today Visitors
+
+
+
+
+
23,485
+
+ +
+
+
2.34% vs. last week
+
+
+
+
+
+
+
+
+
+
+
+
Sales Statistics
+
+
+ +
+
+
    +
  • +
    + + Total Order +
    +
  • +
  • +
    + + Cancelled Order +
    +
  • +
+
+ +
+
+
01 Jul, 2020
+
30 Jul, 2020
+
+
+
+
+
+
+
+
+
+
+
+
Order Statistics
+
+
+
+ +
+
    +
  • +
    + + Completed +
    +
  • +
  • +
    + + Processing +
    +
  • +
  • +
    + + Cancelled +
    +
  • +
+
+
+
+
+
+
+
+
+
+
Store Statistics
+
+
+
    +
  • +
    +
    Orders
    +
    1,795
    +
    + +
  • +
  • +
    +
    Customers
    +
    2,327
    +
    + +
  • +
  • +
    +
    Products
    +
    674
    +
    + +
  • +
  • +
    +
    Categories
    +
    68
    +
    + +
  • +
+
+
+
+
+
+
+
+
+
Recent Orders
+
+
+
+
+
+
Order No.
+
Customer
+
Date
+
Amount
+
Status
+
+
+
+ #95954 +
+
+
+
+ AB +
+
+ Abu Bin Ishtiyak +
+
+
+
+ 02/11/2020 +
+
+ 4,596.75 USD +
+
+ Paid +
+
+
+
+ #95850 +
+
+
+
+ DE +
+
+ Desiree Edwards +
+
+
+
+ 02/02/2020 +
+
+ 596.75 USD +
+
+ Cancelled +
+
+
+
+ #95812 +
+
+
+
+ +
+
+ Blanca Schultz +
+
+
+
+ 02/01/2020 +
+
+ 199.99 USD +
+
+ Paid +
+
+
+
+ #95256 +
+
+
+
+ NL +
+
+ Naomi Lawrence +
+
+
+
+ 01/29/2020 +
+
+ 1099.99 USD +
+
+ Paid +
+
+
+
+ #95135 +
+
+
+
+ CH +
+
+ Cassandra Hogan +
+
+
+
+ 01/29/2020 +
+
+ 1099.99 USD +
+
+ Due +
+
+
+
+
+
+
+
+
+
+
Top products
+
+
+ +
+
+
    +
  • +
    + +
    +
    +
    Pink Fitness Tracker
    +
    $99.00
    +
    +
    +
    $990.00
    +
    10 Sold
    +
    +
  • +
  • +
    + +
    +
    +
    Purple Smartwatch
    +
    $99.00
    +
    +
    +
    $990.00
    +
    10 Sold
    +
    +
  • +
  • +
    + +
    +
    +
    Black Smartwatch
    +
    $99.00
    +
    +
    +
    $990.00
    +
    10 Sold
    +
    +
  • +
  • +
    + +
    +
    +
    Black Headphones
    +
    $99.00
    +
    +
    +
    $990.00
    +
    10 Sold
    +
    +
  • +
  • +
    + +
    +
    +
    iPhone 7 Headphones
    +
    $99.00
    +
    +
    +
    $990.00
    +
    10 Sold
    +
    +
  • +
+
+
+
+
+
+
+
+
+
+ +@include('partials.dashboard.footer') diff --git a/resources/views/partials/dashboard/footer.blade.php b/resources/views/partials/dashboard/footer.blade.php new file mode 100644 index 0000000..84e066d --- /dev/null +++ b/resources/views/partials/dashboard/footer.blade.php @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + diff --git a/resources/views/partials/dashboard/head.blade.php b/resources/views/partials/dashboard/head.blade.php new file mode 100644 index 0000000..ff6da03 --- /dev/null +++ b/resources/views/partials/dashboard/head.blade.php @@ -0,0 +1,18 @@ + + + + + + + + + + + + + {{$title}} - App Name + + + + + diff --git a/resources/views/partials/dashboard/header.blade.php b/resources/views/partials/dashboard/header.blade.php new file mode 100644 index 0000000..ad00101 --- /dev/null +++ b/resources/views/partials/dashboard/header.blade.php @@ -0,0 +1,102 @@ + +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ diff --git a/resources/views/partials/dashboard/sidebar.blade.php b/resources/views/partials/dashboard/sidebar.blade.php new file mode 100644 index 0000000..5a6a100 --- /dev/null +++ b/resources/views/partials/dashboard/sidebar.blade.php @@ -0,0 +1,179 @@ + +
+ +
+ + + diff --git a/routes/web.php b/routes/web.php index 0235740..460616e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ group(function(){ Route::controller(AuthController::class)->group(function(){ - Route::get('/login', 'login')->name('login'); + Route::get('/login', 'login')->name('login')->middleware('authenticated'); Route::name('auth.')->group(function(){ Route::post('/login', 'loginAction')->name('login.action'); - Route::get('/register', 'register')->name('register'); + Route::get('/register', 'register')->name('register')->middleware('authenticated');; Route::post('/register', 'registerAction')->name('register.action'); - Route::get('/register-success', 'registerSuccess')->name('register.success'); + Route::get('/register-success', 'registerSuccess')->name('register.success')->middleware('authenticated');; Route::get('/logout', 'logout')->name('logout'); }); }); }); -Route::middleware(['auth'])->group(function(){ - +Route::middleware(['auth', 'role:1,2,3,4'])->group(function(){ + Route::name('dashboard.')->group(function(){ + Route::prefix('dashboard')->group(function(){ + Route::controller(OverviewController::class)->group(function(){ + Route::get('/overview', 'index')->name('overview'); + }); + }); + }); });