Commit 522186eb by Siti Aisah

login dashboard mahasiswa

parent e9c81e0d
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use App\Models\User;
use Illuminate\Support\Facades\Redis;
class LoginController extends Controller
{
// public function __construct()
// {
// $this->middleware('guest')->except('logout');
// }
public function index()
{
if (Auth::check()) {
return $this->redirectToDashboard();
}
return view('login');
}
public function login(Request $request)
{
// Validate the request
$request->validate([
'email' => 'required|string|email',
'password' => 'required|string|min:8',
], [
'email.email' => 'Format email tidak valid.',
'password.min' => 'Password harus minimal 8 karakter.',
]);
$user = User::where('email', $request->email)->first();
if (!$user) {
return redirect()->route('login')->with('error', 'Email tidak terdaftar.');
}
$credentials = $request->only('email', 'password');
// Attempt to authenticate the user
if (Auth::attempt($credentials)) {
return $this->redirectToDashboard();
}
// throw ValidationException::withMessages([
// 'email' => [trans('auth.failed')],
// ]);
return redirect()->route('login')->with('error', 'Email atau password Anda salah.');
}
public function logout(Request $request)
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('login');
}
private function redirectToDashboard()
{
$user = Auth::user();
//Mapping roles ke routes
$roleRoutes = [
'admin' => 'admin.dashboard',
'laman' => 'mahasiswa.dashboard',
];
foreach ($roleRoutes as $role => $route) {
if ($user->role == $role) {
return redirect()->route($route);
}
}
Auth::logout();
return redirect()->route('login')->with('error', 'Role tidak dikenal.');
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers\Mahasiswa;
use App\Http\Controllers\Controller;
use App\Http\Support\ValidationRule;
use App\Models\Admin\MsKategori;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
use App\Repositories\BiodataRepository;
use Auth;
class BiodataController extends Controller
{
public function __construct(
BiodataRepository $biodataRepository,
) {
$this->biodataRepository = $biodataRepository;
}
public function index(Request $request){
$biodata = $this->biodataRepository->find(Auth::user()->id);
// $kategori = MsKategori::query()->get();
// $data = [
// 'kategori' => $kategori
// ];
return view('mahasiswa.biodata',compact('biodata'));
}
public function store(Request $request){
$rule = [
'kodekategori' => 'required|string',
'namakategori' => 'required|string',
// 'poinsaku' => 'required|string'
];
$request->validate($rule, ValidationRule::getErrorMessage($rule));
DB::beginTransaction();
try{
$kategori = [
'kode_kategori' => strip_tags($request->kodekategori),
'nama_kategori' => strip_tags($request->namakategori),
// 'poin_saku' => strip_tags($request->poinsaku),
'status' => $request->status
];
MsKategori::query()->create($kategori);
DB::commit();
return Redirect::route('kategori.index')
->with('success', 'Data kategori berhasil ditambahkan');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return Redirect::route('kategori.index')
->with('error', 'Data kategori gagal ditambahkan');
}
}
public function update(Request $request, $id){
$rule = [
'kodekategori' => 'required|string',
'namakategori' => 'required|string',
// 'poinsaku' => 'required|string'
];
$request->validate($rule, ValidationRule::getErrorMessage($rule));
DB::beginTransaction();
try{
$id = decrypt($id);
$kategori = [
'kode_kategori' => strip_tags($request->kodekategori),
'nama_kategori' => strip_tags($request->namakategori),
// 'poin_saku' => strip_tags($request->poinsaku),
'status' => $request->status
];
MsKategori::where('id', $id)->update($kategori);
DB::commit();
return Redirect::route('kategori.index')
->with('success', 'Data kategori berhasil diupdate');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return Redirect::route('kategori.index')
->with('error', 'Data kategori gagal diupdate');
}
}
public function destroy($id) {
$id = decrypt($id);
DB::beginTransaction();
try{
MsKategori::where('id', $id)->delete();
DB::commit();
return Redirect::route('kategori.index')
->with('success', 'Data kategori berhasil dihapus');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return Redirect::route('kategori.index')
->with('error', 'Data kategori gagal dihapus');
}
}
}
<?php
namespace App\Http\Controllers\Mahasiswa;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
class DashboardController extends Controller
{
public function index() {
// $data['jumlah'] = DB::table("tr_pengajuan")
// ->select("id_kategori", DB::raw("count (id_kategori) as jumlah"))
// ->groupBy("id_kategori")
// ->pluck('jumlah','id_kategori');
// $semua = DB::table('bantuan_pengusul')->count();
// $sudah = DB::table('tr_pengajuan')->count();
// $data['sudah'] = $sudah;
// $data['belum'] = $semua-$sudah;
return view('mahasiswa.dashboard');
}
}
......@@ -64,5 +64,6 @@ class Kernel extends HttpKernel
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'prevent-back-history' => \App\Http\Middleware\PreventBackHistory::class,
'role' => \App\Http\Middleware\Role::class,
];
}
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Session;
use Auth;
class Role
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function __construct(Request $request)
{
$this->req = $request;
}
public function handle($request, Closure $next, $role)
{
$roles = $this->getAllRoleName($request->route());
// dd(auth()->user()->is_active);
if (auth()->user()) {
if (auth()->user()->is_active == 1) {
if (auth()->user()->role) {
$level = auth()->user()->role;
} else {
// Session::put('ss_status_user', 'naktif');
$level = 'no-access';
Auth::logout();
return redirect('non-active');
}
} else {
// Session::put('ss_status_user', 'naktif');
$level = 'no-access';
Auth::logout();
return redirect('non-active');
}
} else {
$level = 'no-access';
return redirect('/');
}
$roles = explode('_', $role);
$x = 0;
foreach ($roles as $r) {
if ($level == $r) {
$x = 1;
}
}
if ($x == 1) {
return $next($request);
}
Session::put('ss_x', 'noaccess');
return redirect('home');
}
private function getAllRoleName($route)
{
$actions = $route->getAction();
return isset($actions['roles']) ? $actions['roles'] : null;
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Pendaftar extends Model
{
public $incrementing = false;
protected $table = 'ms_pendaftar';
public $timestamps = false;
public static $rules = [
'namapeserta' => 'required',
'tempatlahir' => 'required|regex:/^[a-zA-z]+([\s][a-zA-Z]+)*$/',
'kewarganegaraan' => 'required',
'jenjang' => 'required',
'nik' => 'required_if:kewarganegaraan,ID|digits:16|nullable',
'tgllahir' => 'required|date|before:-13 years',
'sex' => 'required',
'kodeagama' => 'required',
'id_prop_wil' => 'required_if:kewarganegaraan,ID',
'id_kab_wil' => 'required_if:kewarganegaraan,ID',
'id_kec_wil' => 'required_if:kewarganegaraan,ID',
'alamat' => 'required',
'desa' => 'required',
'dusun' => 'required',
'rt' => 'required',
'rw' => 'required',
'kodepos' => 'required',
'email' => 'required',
'hp' => 'min:10|required',
'namaayah' => 'required|different:namaibu',
'namaibu' => 'required|different:namaayah',
// 'nik_ayah' => 'digits:16|required|different_if:nik_ibu,nik',
// 'nik_ibu' => 'digits:16|required|different:nik_ayah,nik',
// 'alamatsmu' => 'required',
// 'kodepossmu' => 'required',
// 'smukelas' => 'required',
'smutahun' => 'required',
// 'kodejurusan' => 'required',
'sttbtahun' => 'required',
'iskebutuhankhusus' => 'required',
// 'nisn' => 'digits:10|nullable',
// 'akreditasi_sekolah' => 'required',
// 'kodesmu' => 'required_if:kewarganegaraan,ID',
'jenis_kebutuhankhusus' => 'required_if:iskebutuhankhusus,Y'
];
public static $errormessage = [
'required' => 'Form Input Ini Tidak Boleh Kosong / Harus Diisi',
'digits' => 'NIK harus 16 digit',
'regex' => 'Tidak Boleh Berisikan Angka',
'before' => 'Minimal Usia 13 Tahun',
'min' => 'Minimal 10 angka',
'different' => 'Nama Ayah dan Ibu Harus Berbeda atau NIK Ayah dan NIK Ibu Harus Berbeda',
];
}
......@@ -2,43 +2,30 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Admin\MsKonselor;
use App\Models\Admin\TrKeahlianKonselor;
use App\Models\Role;
use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Spatie\Permission\Traits\HasRoles;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasFactory, Notifiable, Uuid, HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
public $incrementing = false;
protected $table = 'users';
protected $primaryKey = 'id';
protected $keyType = 'string';
protected $fillable = [
'name',
'email',
'password',
'id', 'name', 'email', 'password', 'role', 'is_active', 'userid_created', 'userid_updated', 'nohp', 'mt_rekanan_id','id_sp','id_prodi','id_sms','prodi'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
'password', 'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
}
\ No newline at end of file
......@@ -44,7 +44,7 @@ public function boot(): void
});
Fortify::loginView(function(){
return view('Admin.login');
return view('login');
});
}
}
<?php
namespace App\Repositories;
use App\Models\Pendaftar;
use Auth;
use Illuminate\Support\Str;
use Session;
use Storage;
use Uuid;
use DB;
class BiodataRepository
{
private $model;
public function __construct(Pendaftar $model)
{
$this->model = $model;
}
public function find($id = null, $with = null)
{
return $this->model
->when($with, function ($query) use ($with) {
return $query->with($with);
})
->when($id, function ($query) use ($id) {
return $query->where('id_user', $id);
})
->firstOrFail();
}
}
......@@ -195,6 +195,7 @@
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
],
......@@ -210,6 +211,8 @@
*/
'aliases' => Facade::defaultAliases()->merge([
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// 'ExampleClass' => App\Example\ExampleClass::class,
])->toArray(),
......
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Dashboard') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
{{ __('You are logged in!') }}
</div>
</div>
</div>
</div>
</div>
@endsection
<ul class="nav navbar-nav" id="main-menu-navigation" data-menu="menu-navigation">
<li data-menu="" class="{{ (request()->is('/home')) ? 'active' : '' }}"><a href="{{url('/')}}" class="dropdown-item nav-link d-flex align-items-center" data-bs-toggle="" data-i18n="Dashboards"><i data-feather="home"></i><span data-i18n="Dashboards">Dashboards</span></a></li>
{{-- @if (Auth::user()->hasAnyRole('admin', 'superadmin')) --}}
<li class="dropdown nav-item" data-menu="dropdown"><a class="dropdown-toggle nav-link d-flex align-items-center" href="#" data-bs-toggle="dropdown"><i data-feather="server"></i><span data-i18n="Data Master">Data Master</span></a>
<ul class="dropdown-menu" data-bs-popper="none">
<li data-menu="" class="{{ (request()->getRequestUri() == "/kategori") ? 'active' : '' }}"><a href="{{route('kategori.index')}}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather="grid"></i><span data-i18n="Email">Master Kategori</span></a>
</li>
<li data-menu="" class="{{ (request()->getRequestUri() == "/user") ? 'active' : '' }}"><a href="{{route('user.index')}}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather='user'></i><span data-i18n="Email">Master User</span></a>
</li>
<li data-menu="" class="{{ (request()->getRequestUri() == "/periode") ? 'active' : '' }}"><a href="{{route('periode.index')}}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather='calendar'></i><span data-i18n="Email">Master Periode</span></a>
</li>
</ul>
</li>
<li class="dropdown nav-item" data-menu="dropdown"><a class="dropdown-toggle nav-link d-flex align-items-center" href="#" data-bs-toggle="dropdown"><i data-feather='edit'></i><span data-i18n="Apps">Transaksi</span></a>
<ul class="dropdown-menu" data-bs-popper="none">
<li data-menu="" class="{{ (request()->getRequestUri() == "/transaksi") ? 'active' : '' }}"><a href="{{ route('transaksi.index') }}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather="check-square"></i><span data-i18n="Email">Update Kategori</span></a>
</li>
<li data-menu="" class="{{ (request()->getRequestUri() == "/saku") ? 'active' : '' }}"><a href="{{ route('saku.index') }}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Todo" ><i data-feather='log-in'></i><span data-i18n="Todo">Tarik Data SAKU</span></a>
</li>
</ul>
</li>
<li class="dropdown nav-item" data-menu="dropdown"><a class="dropdown-toggle nav-link d-flex align-items-center" href="#" data-bs-toggle="dropdown"><i data-feather='file-text'></i><span data-i18n="Dashboards">Laporan</span></a>
<ul class="dropdown-menu" data-bs-popper="none">
<li data-menu="" class="{{ (request()->getRequestUri() == "/laporan") ? 'active' : '' }}"><a class="dropdown-item d-flex align-items-center" href="{{ route('laporan.index') }}" data-bs-toggle="" data-i18n="pembayaran"><i data-feather='clipboard'></i><span data-i18n="pembayaran">SAKU Reviewer</span></a>
</li>
</ul>
</li>
{{-- @endif --}}
@if(Auth::user()->role == 'laman')
<li data-menu="" class="{{ (request()->is('/home')) ? 'active' : '' }}"><a href="{{url('/')}}" class="dropdown-item nav-link d-flex align-items-center" data-bs-toggle="" data-i18n="Dashboard"><i data-feather="home"></i><span data-i18n="Dashboards">Dashboard</span></a></li>
<li class="dropdown nav-item" data-menu="dropdown"><a class="dropdown-toggle nav-link d-flex align-items-center" href="#" data-bs-toggle="dropdown"><i data-feather="clipboard"></i><span data-i18n="Data">Data Calon Mahasiswa</span></a>
<ul class="dropdown-menu" data-bs-popper="none">
<li data-menu="" class="{{ (request()->getRequestUri() == "/biodata") ? 'active' : '' }}"><a href="{{route('biodata.index')}}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather="grid"></i><span data-i18n="Email">Biodata</span></a>
</li>
<li data-menu="" class="{{ (request()->getRequestUri() == "/dokumen") ? 'active' : '' }}"><a href="" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather='image'></i><span data-i18n="Email">Upload Data Pendukung</span></a>
</li>
</ul>
</li>
<li data-menu="" class="{{ (request()->is('/home')) ? 'active' : '' }}"><a href="{{url('/')}}" class="dropdown-item nav-link d-flex align-items-center" data-bs-toggle="" data-i18n="Pengumuman"><i data-feather="calendar"></i><span data-i18n="Pengumuman">Pengumuman</span></a></li>
@endif
</ul>
<!DOCTYPE html>
<html class="loading" lang="en" data-textdirection="ltr">
<!-- BEGIN: Head-->
<head>
<link rel="apple-touch-icon" href="{{ url('theme/images/ico/apple-icon-120.png') }}">
<link rel="shortcut icon" type="image/x-icon" href="{{ url('theme/images/ico/favicon.ico') }}">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500;1,600" rel="stylesheet">
<meta http-equiv="Content-Type" charset="utf-8">
<meta name="universitas-negeri-surabaya" content="custom" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Golden Ticket UNESA">
<meta name="author" content="PPTI Unesa Surabaya">
<meta name="keywords" content="sistem, informasi, unesa, seleksi, penerimaan, mahasiswa, maba">
<meta name="language" content="id">
<meta name="geo.region" content="ID" />
<meta name="geo.position" content="-7.300818;112.672689">
<meta name="geo.placename" content="Surabaya">
<meta name="geo.region" content="Indonesia">
<title>Golden Ticket UNESA</title>
<!-- BEGIN: Vendor CSS-->
<link rel="stylesheet" type="text/css" href="{{ url('theme/vendors/css/vendors.min.css') }}">
<!-- END: Vendor CSS-->
<!-- BEGIN: Theme CSS-->
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/bootstrap.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/bootstrap-extended.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/colors.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/components.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/themes/dark-layout.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/themes/bordered-layout.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/themes/semi-dark-layout.css') }}">
<!-- BEGIN: Page CSS-->
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/core/menu/menu-types/horizontal-menu.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/plugins/forms/form-validation.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/pages/authentication.css') }}">
<!-- END: Page CSS-->
<!-- BEGIN: Custom CSS-->
<link rel="stylesheet" type="text/css" href="{{ url('theme/assets/css/style.css') }}">
<!-- END: Custom CSS-->
</head>
<!-- END: Head-->
<!-- BEGIN: Body-->
<body class="horizontal-layout horizontal-menu blank-page navbar-floating footer-static " data-open="hover" data-menu="horizontal-menu" data-col="blank-page">
<!-- BEGIN: Content-->
<div class="app-content content ">
<div class="content-overlay"></div>
<div class="header-navbar-shadow"></div>
<div class="content-wrapper">
<div class="content-header row">
</div>
<div class="content-body">
<div class="auth-wrapper auth-basic px-2">
<div class="auth-inner my-2">
<!-- Login basic -->
<div class="card mb-0">
<div class="card-body">
<a href="index.html" class="brand-logo">
{{-- <img src="{{ url('theme/images/logo/logoumc.png') }}" width="40%"> --}}
<h2 class="brand-text text-primary ms-1">Golden Ticket UNESA</h2>
</a>
@if(Session::has('message'))
<div class="alert alert-success" style="float:none">
{{ Session::get('message') }}
{{Session::forget('message')}}
</div>
@endif
<form class="text-left" method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group" >
<div class="col-md-12">
@if ($errors->has('email'))
<div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>{{ $errors->first('email') }}</strong>
</div>
@endif
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required placeholder="Masukkan Email">
</div>
</div><br>
<div class="form-group" >
<div class="col-md-12">
@if ($errors->has('password'))
<div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>{{ $errors->first('password') }}</strong>
</div>
@endif
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" value="{{ old('password') }}" required placeholder="Masukkan Password">
</div>
</div><br>
<button type="submit" class="btn btn-primary w-100" tabindex="4">Login</button>
<div class="cold-md-6 mt-1">
Belum punya akun? <a href="{{ route('register') }}">Daftar di sini</a>
</div>
</form>
</br>
</div>
</div>
<!-- /Login basic -->
</div>
</div>
</div>
</div>
</div>
<!-- END: Content-->
<!-- BEGIN: Vendor JS-->
<script src="{{ url('theme/vendors/js/vendors.min.js') }}"></script>
<!-- BEGIN Vendor JS-->
<!-- BEGIN: Page Vendor JS-->
<script src="{{ url('theme/vendors/js/ui/jquery.sticky.js') }}"></script>
<script src="{{ url('theme/vendors/js/forms/validation/jquery.validate.min.js') }}"></script>
<!-- END: Page Vendor JS-->
<!-- BEGIN: Theme JS-->
<script src="{{ url('theme/js/core/app-menu.js') }}"></script>
<script src="{{ url('theme/js/core/app.js') }}"></script>
<!-- END: Theme JS-->
<!-- BEGIN: Page JS-->
<script src="{{ url('theme/js/scripts/pages/auth-login.js') }}"></script>
<!-- END: Page JS-->
<script>
$(window).on('load', function() {
if (feather) {
feather.replace({
width: 14,
height: 14
});
}
})
</script>
</body>
<!-- END: Body-->
</html>
<?php
use App\Http\Controllers\Admin\Auth\LoginController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\KategoriController;
use App\Http\Controllers\Admin\LaporanController;
use App\Http\Controllers\Admin\PeriodeController;
use App\Http\Controllers\Admin\TransaksiController;
use App\Http\Controllers\Admin\SakuController;
use App\Http\Controllers\Admin\UserController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Mahasiswa\BiodataController;
use App\Http\Controllers\Mahasiswa\DashboardController;
/*
|--------------------------------------------------------------------------
......@@ -21,20 +16,35 @@
|
*/
Route::get('login', [LoginController::class, 'index'])->name('login');
Route::post('login', [LoginController::class, 'login']);
Route::post('logout', [LoginController::class, 'logout'])->name('logout');
// Route::get('sso/{email}/{sessionid}', [LoginController::class, 'sso']);
Route::get('/', function () {
return view('Admin.login');
if (auth()->check()) {
if (auth()->user()->role == 'laman') {
return redirect()->route('mahasiswa.dashboard');
}
elseif (auth()->user()->role == 'admin') {
return redirect()->route('admin.dashboard');
} else {
return redirect()->route('login');
}
}
return redirect()->route('login');
});
// Route::get('/home', [TransaksiController::class, 'index'])->name('admin.index-transaksi');
Route::middleware(['auth','prevent-back-history'])->group(function(){
Route::get('/home', [DashboardController::class, 'index']);
Route::resource('kategori', KategoriController::class);
Route::resource('transaksi', TransaksiController::class);
Route::resource('saku', SakuController::class);
Route::resource('laporan', LaporanController::class);
Route::post('/excel', [LaporanController::class, 'download'])->name('laporan.download');
Route::resource('user', UserController::class);
Route::resource('periode', PeriodeController::class);
Route::get('/logout', [LoginController::class, 'logout'])->name('admin.logout');
Route::middleware('auth')->group(function () {
// Routes for Admin
// Routes for Mahasiswa
Route::prefix('pendaftar')->middleware('role:laman')->group(function () {
Route::get('dashboard', [DashboardController::class, 'index'])->name('mahasiswa.dashboard');
Route::resource('biodata', BiodataController::class);
});
});
Route::get('/logout', [LoginController::class, 'logout'])->name('admin.logout');
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment