login guru updated
This commit is contained in:
parent
55ba55e100
commit
b1add7f3e3
|
|
@ -17,6 +17,7 @@ public function showLoginForm()
|
|||
// Proses login
|
||||
public function login(Request $request)
|
||||
{
|
||||
// Validasi input
|
||||
$request->validate([
|
||||
'nip' => 'required',
|
||||
'password' => 'required',
|
||||
|
|
@ -24,18 +25,20 @@ public function login(Request $request)
|
|||
|
||||
$credentials = $request->only('nip', 'password');
|
||||
|
||||
// Attempt login dengan guard 'guru'
|
||||
if (Auth::guard('guru')->attempt($credentials)) {
|
||||
$request->session()->regenerate();
|
||||
|
||||
|
||||
return redirect()->intended(route('guru.dashboard'));
|
||||
}
|
||||
|
||||
// Kalau gagal login
|
||||
return back()->withErrors([
|
||||
'nip' => 'NIP atau password salah'
|
||||
])->withInput($request->except('password'));
|
||||
'nip' => 'NIP atau password salah!',
|
||||
])->withInput($request->only('nip'));
|
||||
}
|
||||
|
||||
// Logout
|
||||
// Proses logout
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::guard('guru')->logout();
|
||||
|
|
|
|||
|
|
@ -3,27 +3,30 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Tentukan ke mana redirect jika user belum login.
|
||||
*/
|
||||
protected function redirectTo($request): ?string{
|
||||
if (! $request->expectsJson()) {
|
||||
// Admin
|
||||
if ($request->is('admin/*')) {
|
||||
return route('admin.login');
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
// Cek guard mana yang dipake
|
||||
if ($request->is('admin/*')) {
|
||||
return route('admin.login');
|
||||
}
|
||||
|
||||
if ($request->is('guru/*')) {
|
||||
return route('guru.login');
|
||||
}
|
||||
|
||||
if ($request->is('siswa/*')) {
|
||||
return route('siswa.login');
|
||||
}
|
||||
|
||||
// Default ke landing page
|
||||
return route('landing-page');
|
||||
}
|
||||
|
||||
// Guru
|
||||
if ($request->is('guru/*')) {
|
||||
return route('guru.login');
|
||||
}
|
||||
|
||||
// Default
|
||||
return route('login');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}}
|
||||
}
|
||||
|
|
@ -38,16 +38,19 @@
|
|||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'user',
|
||||
'provider' => 'users',
|
||||
],
|
||||
|
||||
'admin' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'admin',
|
||||
'provider' => 'admins',
|
||||
],
|
||||
|
||||
'guru' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'gurus',
|
||||
],
|
||||
|
||||
'siswa' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'siswas',
|
||||
|
|
@ -72,20 +75,23 @@
|
|||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'user' => [
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
'admin' => [
|
||||
|
||||
'admins' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Admin::class,
|
||||
],
|
||||
|
||||
'gurus' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Guru::class,
|
||||
],
|
||||
'siswa' => [
|
||||
|
||||
'siswas' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Siswa::class,
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,69 +1,62 @@
|
|||
|
||||
@extends('layouts.auth')
|
||||
|
||||
@section('title', 'Login Guru')
|
||||
|
||||
@section('content')
|
||||
<div class="card p-4 shadow" style="width: 400px;">
|
||||
<h4 class="text-center mb-4 fw-bold text-primary">Login Guru</h4>
|
||||
|
||||
{{-- Tombol Back ke Landing Page --}}
|
||||
<a href="{{ url('/') }}" class="btn btn-outline-secondary mb-3">
|
||||
← Kembali ke Landing Page
|
||||
</a>
|
||||
|
||||
{{-- Alert Error --}}
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
{{ $errors->first() }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login Guru - E-Learning</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-card {
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
padding: 40px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
||||
max-width: 450px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-card">
|
||||
<h2 class="text-center mb-4">👨🏫 Login Guru</h2>
|
||||
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
{{ $errors->first() }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form action="{{ route('guru.login.submit') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">NIP</label>
|
||||
<input type="text" name="nip" class="form-control"
|
||||
value="{{ old('nip') }}" required autofocus>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Password</label>
|
||||
<input type="password" name="password" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
LOGIN
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="text-center mt-3">
|
||||
<a href="{{ route('landing-page') }}" class="text-muted">
|
||||
← Kembali ke Halaman Utama
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('guru.login.submit') }}">
|
||||
@csrf
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">NIP</label>
|
||||
<input type="text" name="nip" class="form-control @error('nip') is-invalid @enderror"
|
||||
value="{{ old('nip') }}" required>
|
||||
@error('nip')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 position-relative">
|
||||
<label class="form-label">Password</label>
|
||||
<div class="input-group">
|
||||
<input type="password" name="password" id="password"
|
||||
class="form-control @error('password') is-invalid @enderror" required>
|
||||
<button type="button" class="btn btn-outline-secondary" id="togglePassword">
|
||||
👁️
|
||||
</button>
|
||||
</div>
|
||||
@error('password')
|
||||
<div class="invalid-feedback d-block">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- Remember Me --}}
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" name="remember" id="remember">
|
||||
<label class="form-check-label" for="remember">
|
||||
Remember Me
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100">Masuk</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{-- Script show/hide password --}}
|
||||
<script>
|
||||
document.getElementById('togglePassword').addEventListener('click', function() {
|
||||
const password = document.getElementById('password');
|
||||
const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
|
||||
password.setAttribute('type', type);
|
||||
this.textContent = type === 'password' ? '👁️' : '🙈';
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,294 +1,74 @@
|
|||
<?php?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>@yield('title', 'Panel Guru')</title>
|
||||
|
||||
<!-- Fonts & Bootstrap -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<title>@yield('title', 'E-Learning Guru')</title>
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
background-color: #f8f9fa;
|
||||
margin: 0;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
/* WRAPPER */
|
||||
.guru-wrapper {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* SIDEBAR */
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
background: #ffffff;
|
||||
border-right: 2px solid #e0f2fe;
|
||||
padding: 30px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.sidebar-logo img {
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 18px;
|
||||
margin-bottom: 12px;
|
||||
border-radius: 12px;
|
||||
color: #64748b;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar-link:hover {
|
||||
background: #e0f2fe;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
.sidebar-link.active {
|
||||
background: #e0f2fe;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
.sidebar-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sidebar-logout {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.sidebar-logout button {
|
||||
width: 100%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #ef4444;
|
||||
font-weight: 600;
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* MAIN */
|
||||
.main {
|
||||
flex: 1;
|
||||
background: #f0f9ff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* TOPBAR */
|
||||
.topbar {
|
||||
background: #0284c7;
|
||||
margin: 20px;
|
||||
padding: 16px 24px;
|
||||
border-radius: 16px;
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.topbar-left {
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.topbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.topbar-icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* CONTENT */
|
||||
.content {
|
||||
padding: 20px 30px;
|
||||
flex: 1;
|
||||
.content-area {
|
||||
padding: 30px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@stack('styles')
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="guru-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- SIDEBAR -->
|
||||
<div class="col-md-2 sidebar p-0">
|
||||
<div class="p-4">
|
||||
<h4 class="mb-4">📚 E-Learning</h4>
|
||||
<nav class="nav flex-column">
|
||||
<a href="{{ route('guru.dashboard') }}" class="nav-link text-white">
|
||||
🏠 Dashboard
|
||||
</a>
|
||||
<a href="{{ route('guru.guru.index') }}" class="nav-link text-white">
|
||||
👨🏫 Daftar Guru
|
||||
</a>
|
||||
<a href="{{ route('guru.kelas.index') }}" class="nav-link text-white">
|
||||
🏫 Daftar Kelas
|
||||
</a>
|
||||
<a href="{{ route('guru.siswa.index') }}" class="nav-link text-white">
|
||||
👨🎓 Daftar Siswa
|
||||
</a>
|
||||
<a href="{{ route('guru.profil.show') }}" class="nav-link text-white">
|
||||
👤 Profil
|
||||
</a>
|
||||
<hr class="bg-white">
|
||||
<form action="{{ route('guru.logout') }}" method="POST">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-danger w-100">
|
||||
🚪 Logout
|
||||
</button>
|
||||
</form>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SIDEBAR -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-logo">
|
||||
<img src="{{ asset('images/logo/logosmk.png') }}" alt="Logo SMK">
|
||||
<!-- MAIN CONTENT -->
|
||||
<div class="col-md-10 content-area">
|
||||
@yield('content')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="sidebar-menu">
|
||||
|
||||
<a href="{{ route('guru.dashboard') }}"
|
||||
class="sidebar-link {{ request()->routeIs('guru.dashboard') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/home.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Dashboard</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.guru.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('guru.guru.*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/guru.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Daftar Guru</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.kelas.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('guru.kelas.*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/kelas.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Daftar Kelas</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.siswa.index') }}"
|
||||
class="sidebar-link {{ request()->routeIs('guru.siswa.*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/siswa.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Daftar Siswa</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ route('guru.profil.show') }}"
|
||||
class="sidebar-link {{ request()->routeIs('guru.profil.*') ? 'active' : '' }}">
|
||||
<img src="{{ asset('images/icon/sidebar/profil.png') }}" class="sidebar-icon" alt="">
|
||||
<span>Profil Saya</span>
|
||||
</a>
|
||||
|
||||
</nav>
|
||||
|
||||
<form action="{{ route('guru.logout') }}" method="POST" class="sidebar-logout">
|
||||
@csrf
|
||||
<button type="submit">Logout</button>
|
||||
</form>
|
||||
</aside>
|
||||
|
||||
<!-- MAIN -->
|
||||
<div class="main">
|
||||
|
||||
<!-- TOPBAR -->
|
||||
<header class="topbar">
|
||||
<div class="topbar-left">
|
||||
👋 Hai, {{ Auth::guard('guru')->user()->nama ?? 'Guru' }}
|
||||
</div>
|
||||
|
||||
<div class="topbar-right">
|
||||
<img src="{{ asset('images/icon/sidebar/notif.png') }}" class="topbar-icon" alt="Notification">
|
||||
<img src="{{ asset('images/icon/sidebar/profil.png') }}" class="topbar-icon" alt="Profile">
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- CONTENT -->
|
||||
<main class="content">
|
||||
@yield('content')
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
@stack('scripts')
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<?php
|
||||
// ============================================================
|
||||
// FILE 10: resources/views/guru/dashboard.blade.php
|
||||
// ============================================================
|
||||
?>
|
||||
|
||||
@extends('guru.layouts.app')
|
||||
|
||||
@section('title', 'Dashboard Guru')
|
||||
|
||||
@section('content')
|
||||
|
||||
<style>
|
||||
.page-title {
|
||||
font-size: 30px;
|
||||
font-weight: 800;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stats-card {
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
padding: 25px;
|
||||
border: 2px solid #e0f2fe;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stats-number {
|
||||
font-size: 48px;
|
||||
font-weight: 700;
|
||||
color: #0284c7;
|
||||
}
|
||||
|
||||
.stats-label {
|
||||
font-size: 16px;
|
||||
color: #64748b;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.welcome-card {
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
padding: 30px;
|
||||
border: 2px solid #e0f2fe;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h3 class="page-title">DASHBOARD GURU</h3>
|
||||
|
||||
<div class="welcome-card">
|
||||
<h4>Selamat Datang, {{ Auth::guard('guru')->user()->nama }}! 👨🏫</h4>
|
||||
<p class="text-muted mb-0">NIP: {{ Auth::guard('guru')->user()->nip }}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="stats-card">
|
||||
<div class="stats-number">{{ $totalKelas }}</div>
|
||||
<div class="stats-label">Total Kelas Diampu</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="stats-card">
|
||||
<div class="stats-number">{{ $totalMapel }}</div>
|
||||
<div class="stats-label">Total Mata Pelajaran</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="stats-card">
|
||||
<div class="stats-number">{{ $totalSiswa }}</div>
|
||||
<div class="stats-label">Total Siswa Diajar</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
</html>
|
||||
Loading…
Reference in New Issue