33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Cbt;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Models\Exam;
|
||
|
|
use App\Models\ExamResult;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Support\Facades\Auth;
|
||
|
|
|
||
|
|
class UserDashboardController extends Controller
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Menampilkan Dashboard Portal Ujian Karyawan
|
||
|
|
*/
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
// Ambil data user yang sedang login
|
||
|
|
$user = Auth::user();
|
||
|
|
|
||
|
|
// Tarik riwayat ujian yang pernah diikuti karyawan ini beserta detail ujiannya
|
||
|
|
$examHistory = ExamResult::where('user_id', $user->id)
|
||
|
|
->with('exam')
|
||
|
|
->orderBy('created_at', 'desc')
|
||
|
|
->get();
|
||
|
|
|
||
|
|
// Tarik daftar ujian yang tersedia (Bisa ditambahkan filter berdasarkan departemen/jabatan nanti)
|
||
|
|
$availableExams = Exam::orderBy('created_at', 'desc')->get();
|
||
|
|
|
||
|
|
// Kirim data ke view dashboard CBT
|
||
|
|
return view('pages.cbt.dashboard.dashboard', compact('user', 'examHistory', 'availableExams'));
|
||
|
|
}
|
||
|
|
}
|