Files
siakad/app/Http/Controllers/Dosen/BimbinganController.php
T
2026-10-24 11:45:32 +07:00

86 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers\Dosen;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\DosenData;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
class BimbinganController extends ResourceController
{
protected function rows(): Collection
{
return DosenData::bimbingan();
}
protected function keyName(): string
{
return 'nim';
}
protected function routeBase(): string
{
return 'dosen.bimbingan';
}
protected function names(): array
{
return ['singular' => 'Mahasiswa', 'plural' => 'Mahasiswa bimbingan', 'description' => 'Mahasiswa yang Anda bimbing sebagai dosen pembimbing akademik.'];
}
protected function abilities(): array
{
return ['create' => false, 'show' => true, 'edit' => false, 'delete' => false];
}
protected function search(): array
{
return ['nim', 'nama'];
}
protected function filters(): array
{
$status = $this->rows()->pluck('status')->unique()->mapWithKeys(fn (string $s): array => [$s => $s])->all();
$angkatan = $this->rows()->pluck('angkatan')->unique()->sortDesc()->mapWithKeys(fn (int $a): array => [(string) $a => (string) $a])->all();
return [
['name' => 'status', 'label' => 'Status', 'options' => $status],
['name' => 'angkatan', 'label' => 'Angkatan', 'options' => $angkatan],
];
}
protected function columns(): array
{
return [
['label' => 'NIM', 'key' => 'nim'],
['label' => 'Nama', 'key' => 'nama'],
['label' => 'Angkatan', 'key' => 'angkatan', 'class' => 'num'],
['label' => 'IPK', 'value' => fn (array $r): string => DosenData::angka($r['ipk']), 'class' => 'num'],
['label' => 'SKS', 'key' => 'sks', 'class' => 'num'],
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): string => match ($r['status']) {
'Aktif' => 'success', 'Cuti' => 'gold', 'Lulus' => 'accent', default => 'danger',
}],
];
}
protected function fields(?array $row): array
{
return [];
}
public function show(string $record): View
{
$mhs = $this->find($record);
$ips = DosenData::ipsRiwayat($mhs['nim']);
return view('dosen.bimbingan.show', [
'mhs' => $mhs,
'ips' => $ips,
'labels' => collect($ips)->keys()->map(fn (int $i): string => 'Sem '.($i + 1))->all(),
'krs' => DosenData::krsBimbingan()->firstWhere('nim', $mhs['nim']),
'skripsi' => DosenData::skripsi()->firstWhere('nim', $mhs['nim']),
]);
}
}