38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?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(),
|
|
]);
|
|
}
|
|
}
|