37 lines
1009 B
PHP
37 lines
1009 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Guru;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Mengajar;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$guru = Auth::guard('guru')->user();
|
|
|
|
// Hitung total kelas yang diajar
|
|
$totalKelas = Mengajar::where('nip', $guru->nip)
|
|
->distinct('id_kelas')
|
|
->count('id_kelas');
|
|
|
|
// Hitung total mapel yang diajar
|
|
$totalMapel = Mengajar::where('nip', $guru->nip)
|
|
->distinct('id_mapel')
|
|
->count('id_mapel');
|
|
|
|
// Hitung total siswa yang diajar (lewat kelas)
|
|
$totalSiswa = Mengajar::where('nip', $guru->nip)
|
|
->with('kelas.siswa')
|
|
->get()
|
|
->pluck('kelas.siswa')
|
|
->flatten()
|
|
->unique('nisn')
|
|
->count();
|
|
|
|
return view('guru.dashboard', compact('totalKelas', 'totalMapel', 'totalSiswa'));
|
|
}
|
|
}
|