Penambahan menu Perkuliahan
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Operator\Concerns;
|
||||
|
||||
use App\Models\Legacy\Account;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/** Bagian bersama pengendali halaman SATU berdata asli: jejak, muatan JSON tabel, penjagaan akun DB lama, per halaman. */
|
||||
trait ServesLegacyList
|
||||
{
|
||||
/** @return array<string, ?string> */
|
||||
protected function crumbs(string $slug, array $page): array
|
||||
{
|
||||
return ['Beranda' => route('operator.dashboard')] + array_fill_keys(Catalog::trail($slug), null) + [$page['title'] => null];
|
||||
}
|
||||
|
||||
/** @return array{rows: list<array<string, mixed>>, page: int, last_page: int, total: int, per_page: int} */
|
||||
protected function payload(LengthAwarePaginator $rows): array
|
||||
{
|
||||
return [
|
||||
'rows' => array_values($rows->items()),
|
||||
'page' => $rows->currentPage(),
|
||||
'last_page' => $rows->lastPage(),
|
||||
'total' => $rows->total(),
|
||||
'per_page' => $rows->perPage(),
|
||||
];
|
||||
}
|
||||
|
||||
/** Hanya akun DB lama yang memegang data asli; akun demo mendapat 404 (halamannya prototipe). */
|
||||
protected function legacyOnly(Request $request): void
|
||||
{
|
||||
abort_unless($request->user() instanceof Account, 404);
|
||||
}
|
||||
|
||||
/** @param list<int> $allowed */
|
||||
protected function perPage(Request $request, array $allowed): int
|
||||
{
|
||||
return in_array($request->integer('per'), $allowed, true) ? $request->integer('per') : $allowed[0];
|
||||
}
|
||||
|
||||
protected function query(Request $request): string
|
||||
{
|
||||
return mb_substr(trim((string) $request->string('q')), 0, 100);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user