Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Operator;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Support\Prototype\OperatorData;
|
||||
use App\Support\Prototype\Sample;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/** Jadwal kuliah mingguan semua kelas, dengan filter ruang dan penanda bentrok. */
|
||||
class JadwalController extends Controller
|
||||
{
|
||||
private const HARI = ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
{
|
||||
$ruangOptions = Sample::ruang()->mapWithKeys(fn (array $r): array => [$r['kode'] => $r['kode'].' - '.$r['nama']])->all();
|
||||
$ruang = (string) $request->query('ruang');
|
||||
$ruang = array_key_exists($ruang, $ruangOptions) ? $ruang : '';
|
||||
|
||||
$semua = OperatorData::tandaiBentrok(Sample::kelas());
|
||||
$tampil = $ruang === '' ? $semua : $semua->where('ruang', $ruang);
|
||||
|
||||
$perHari = collect(self::HARI)->mapWithKeys(fn (string $h) => [
|
||||
$h => $tampil->where('hari', $h)->sortBy(fn (array $k): int => OperatorData::rentangMenit($k['jam'])[0])->values(),
|
||||
]);
|
||||
|
||||
return view('operator.jadwal', [
|
||||
'perHari' => $perHari,
|
||||
'ruangOptions' => $ruangOptions,
|
||||
'ruang' => $ruang,
|
||||
'bentrok' => $semua->filter(fn (array $k): bool => $k['bentrok'] !== [])->values(),
|
||||
'total' => $tampil->count(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user