489 lines
22 KiB
PHP
489 lines
22 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Controllers\Operator;
|
||
|
||
use App\Exports\ReportExport;
|
||
use App\Http\Controllers\Controller;
|
||
use App\Models\Legacy\Account;
|
||
use App\Support\Legacy\AcademicOverview;
|
||
use App\Support\Legacy\PortalException;
|
||
use App\Support\Legacy\Reports\ReportContext;
|
||
use App\Support\Legacy\Reports\ReportRegistry;
|
||
use App\Support\Legacy\Reports\ReportSource;
|
||
use App\Support\Prototype\Satu\Catalog;
|
||
use Illuminate\Contracts\View\View;
|
||
use Illuminate\Http\JsonResponse;
|
||
use Illuminate\Http\RedirectResponse;
|
||
use Illuminate\Http\Request;
|
||
use Maatwebsite\Excel\Excel as ExcelWriter;
|
||
use Maatwebsite\Excel\Facades\Excel;
|
||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||
|
||
/**
|
||
* Menu Laporan operator untuk akun DB lama: formulir parameter yang menjalankan laporan otomatis lewat JSON
|
||
* (tabel berhalaman), unduh CSV (atau Excel lewat maatwebsite/excel bila definisi laporan memuat 'export' => 'xlsx'), dan halaman cetak. Hanya baca. Sumber laporan (ReportSource) hanya mengenal
|
||
* limit, jadi halaman N diambil dengan limit N × per halaman lalu dipotong (dibatasi CAP baris pertama).
|
||
*/
|
||
class LaporanController extends Controller
|
||
{
|
||
/** Pilihan jumlah baris per halaman; bawaan yang kedua. */
|
||
public const array PER_PAGE = [10, 25, 50, 100];
|
||
|
||
/** Baris pertama yang bisa dilihat berhalaman; selebihnya lewat Unduh atau filter yang lebih sempit. */
|
||
private const int CAP = 5000;
|
||
|
||
private const int PRINT = 2000;
|
||
|
||
private const int DOWNLOAD = 50000;
|
||
|
||
private const string XLSX_MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||
|
||
/** Batas memori (byte) dan waktu (detik) selama membangun berkas Excel; lihat raiseExportLimits(). */
|
||
private const int XLSX_MEMORY = 1024 * 1024 * 1024;
|
||
|
||
private const int XLSX_SECONDS = 180;
|
||
|
||
public function __construct(private readonly AcademicOverview $overview) {}
|
||
|
||
public function __invoke(Request $request, string $slug): View
|
||
{
|
||
[$source, $context, $page, $definition] = $this->prepare($request, $slug);
|
||
[$values] = $this->parse($request, $definition['params'], $request->query() !== []);
|
||
|
||
// Semua laporan tampil sebagai daftar biasa (bilah filter + tabel); 'list' => false mengembalikan formulir parameter.
|
||
if ($definition['list'] ?? true) {
|
||
return $this->listPage($request, $slug, $source, $context, $page, $definition, $values);
|
||
}
|
||
|
||
return view('operator.satu.legacy-report', [
|
||
'page' => $page,
|
||
'crumbs' => ['Beranda' => route(auth()->user()->role->dashboardRoute())] + array_fill_keys(Catalog::trail($slug), null) + [$page['title'] => null],
|
||
'slug' => $slug,
|
||
'definition' => $definition,
|
||
'values' => $values,
|
||
'downloadLabel' => self::downloadLabel($definition),
|
||
'downloadVariant' => self::downloadVariant($definition),
|
||
'config' => [
|
||
'url' => route('operator.laporan.data', $slug),
|
||
'downloadUrl' => route('operator.laporan.unduh', $slug),
|
||
'printUrl' => route('operator.laporan.cetak', $slug),
|
||
'params' => array_map(fn (array $p): array => ['name' => $p['name'], 'type' => $p['type'], 'required' => (bool) ($p['required'] ?? false), 'reload' => $p['name'] !== 'kop'], $definition['params']),
|
||
'values' => $this->clientValues($definition['params'], $values),
|
||
'perPage' => self::PER_PAGE,
|
||
'per' => self::PER_PAGE[1],
|
||
],
|
||
]);
|
||
}
|
||
|
||
/** JSON satu halaman hasil: kolom, baris halaman ini, keterangan, dan penomoran. */
|
||
public function data(Request $request, string $slug): JsonResponse
|
||
{
|
||
[$source, $context, , $definition] = $this->prepare($request, $slug);
|
||
[$values, $errors] = $this->parse($request, $definition['params'], true);
|
||
if ($errors !== []) {
|
||
return response()->json(['message' => implode(' ', $errors), 'errors' => $errors], 422);
|
||
}
|
||
|
||
$list = (bool) ($definition['list'] ?? true);
|
||
$filterQ = $this->searchTerm($request, $definition, $values);
|
||
$per = in_array($request->integer('per'), self::PER_PAGE, true) ? $request->integer('per') : self::PER_PAGE[1];
|
||
|
||
try {
|
||
return response()->json($this->pageOf($source, $slug, $values, $context, $per, $request->integer('page', 1), $list, $filterQ));
|
||
} catch (PortalException $e) {
|
||
return response()->json(['message' => $e->getMessage()], 422);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Kata cari dari kotak cari daftar. Sumber yang mengenal kata cari menerimanya sebagai parameter q ($values diisi);
|
||
* selain itu kata cari dikembalikan untuk saringan generik atas semua kolom hasil. Null bila tidak ada yang perlu
|
||
* disaring di sini (tanpa kata cari, bukan daftar, atau laporan punya parameter q sendiri).
|
||
*
|
||
* @param array<string, mixed> $definition
|
||
* @param array<string, mixed> $values
|
||
*/
|
||
private function searchTerm(Request $request, array $definition, array &$values): ?string
|
||
{
|
||
$raw = $request->input('q');
|
||
$q = is_string($raw) ? mb_substr(trim($raw), 0, 100) : '';
|
||
if ($q === '' || ! ($definition['list'] ?? true)) {
|
||
return null;
|
||
}
|
||
|
||
if ($definition['search'] ?? false) {
|
||
$values['q'] = $q;
|
||
|
||
return null;
|
||
}
|
||
|
||
return self::hasParam($definition, 'q') ? null : $q;
|
||
}
|
||
|
||
/**
|
||
* Baris yang salah satu kolomnya memuat kata cari (tanpa membedakan huruf besar/kecil). Kunci berawalan "_"
|
||
* (penanda, bukan kolom) tidak ikut dicari.
|
||
*
|
||
* @param list<array<string, mixed>> $rows
|
||
* @return list<array<string, mixed>>
|
||
*/
|
||
private static function matching(array $rows, string $q): array
|
||
{
|
||
$needle = mb_strtolower($q);
|
||
|
||
return array_values(array_filter($rows, function (array $row) use ($needle): bool {
|
||
foreach ($row as $key => $value) {
|
||
if (is_scalar($value) && ! str_starts_with((string) $key, '_') && str_contains(mb_strtolower((string) $value), $needle)) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}));
|
||
}
|
||
|
||
/** Laporan punya parameter bernama {name}? */
|
||
private static function hasParam(array $definition, string $name): bool
|
||
{
|
||
return in_array($name, array_column($definition['params'], 'name'), true);
|
||
}
|
||
|
||
/**
|
||
* Satu halaman hasil laporan: kolom, baris halaman ini, keterangan, dan penomoran (baris diberi id urut bila daftar).
|
||
*
|
||
* @param array<string, mixed> $values
|
||
* @return array<string, mixed>
|
||
*/
|
||
private function pageOf(ReportSource $source, string $slug, array $values, ReportContext $context, int $per, int $page, bool $list = false, ?string $filterQ = null): array
|
||
{
|
||
$maxPage = intdiv(self::CAP + $per - 1, $per);
|
||
$page = min(max(1, $page), $maxPage);
|
||
|
||
if ($filterQ !== null) {
|
||
// Kata cari generik: ambil sampai batas CAP lalu saring baris yang salah satu kolomnya memuat kata itu.
|
||
$result = $source->run($slug, $values, $context, self::CAP + 1);
|
||
$all = self::matching($result->markedRows(), $filterQ);
|
||
$total = count($all);
|
||
} else {
|
||
// +1 agar terlihat bila masih ada baris sesudah halaman ini saat sumber tidak mengisi total
|
||
$result = $source->run($slug, $values, $context, $page * $per + 1);
|
||
// Baris penjumlahan membawa penanda ReportResult::TOTAL_KEY agar tabel bisa memberinya arsir
|
||
$all = $result->markedRows();
|
||
$total = $result->total ?? count($all);
|
||
}
|
||
|
||
$lastPage = max(1, min($maxPage, intdiv($total + $per - 1, $per)));
|
||
$page = min($page, $lastPage);
|
||
$from = ($page - 1) * $per + 1;
|
||
$rows = array_values(array_slice($all, $from - 1, $per));
|
||
$columns = $result->columns;
|
||
if ($list) {
|
||
$rows = array_map(fn (array $row, int $i): array => ['id' => $from + $i] + $row, $rows, array_keys($rows));
|
||
// Kolom tabel daftar: tanpa kolom 'hidden' (hanya untuk unduhan); 'meter' = tampil sebagai bar persen.
|
||
$columns = array_values(array_map(
|
||
fn (array $c): array => ['key' => $c['key'], 'label' => $c['label'], 'num' => (bool) ($c['num'] ?? false), 'meter' => (bool) ($c['meter'] ?? false)],
|
||
array_filter($columns, fn (array $c): bool => ! ($c['hidden'] ?? false)),
|
||
));
|
||
}
|
||
|
||
return [
|
||
'columns' => $columns,
|
||
'rows' => $rows,
|
||
'summary' => $result->summary,
|
||
'note' => $result->note,
|
||
'total' => $total,
|
||
'page' => $page,
|
||
'last_page' => $lastPage,
|
||
'per_page' => $per,
|
||
'from' => $from,
|
||
'capped' => $total > self::CAP,
|
||
'cap' => self::CAP,
|
||
];
|
||
}
|
||
|
||
/**
|
||
* Laporan bergaya daftar biasa (remote-list): bilah filter dari parameter laporan (tanpa KOP), tabel dengan kotak cari
|
||
* dan halaman, tautan Unduh CSV di bilah. Kolom diambil dari hasil halaman pertama.
|
||
*
|
||
* @param array<string, mixed> $page
|
||
* @param array<string, mixed> $definition
|
||
* @param array<string, mixed> $values
|
||
*/
|
||
private function listPage(Request $request, string $slug, ReportSource $source, ReportContext $context, array $page, array $definition, array $values): View
|
||
{
|
||
// Parameter laporan menjadi filter daftar: select/check/text/number/date (KOP hanya untuk cetak, dibuang).
|
||
$params = array_values(array_filter($definition['params'], fn (array $p): bool => $p['name'] !== 'kop'));
|
||
$filters = array_map(function (array $p) use ($values): array {
|
||
$filter = ['name' => $p['name'], 'label' => $p['label'].(($p['required'] ?? false) ? '' : '')];
|
||
if ($p['type'] === 'check') {
|
||
return $filter + ['type' => 'check', 'value' => (bool) ($values[$p['name']] ?? false)];
|
||
}
|
||
if ($p['type'] === 'select') {
|
||
return $filter + ['options' => $p['options'] ?? [], 'value' => $values[$p['name']] ?? null];
|
||
}
|
||
|
||
return $filter + ['type' => $p['type'], 'value' => $values[$p['name']] ?? null, 'placeholder' => $p['placeholder'] ?? null, 'hint' => $p['hint'] ?? null];
|
||
}, $params);
|
||
|
||
// Halaman pertama; parameter wajib yang belum terisi atau kesalahan sumber = tabel kosong dengan kolom dinamis dari JSON.
|
||
[, $errors] = $this->parse($request, $definition['params'], true);
|
||
$data = ['columns' => [], 'rows' => [], 'total' => 0, 'page' => 1, 'last_page' => 1, 'per_page' => self::PER_PAGE[0]];
|
||
if ($errors === []) {
|
||
try {
|
||
$data = $this->pageOf($source, $slug, $values, $context, self::PER_PAGE[0], 1, true);
|
||
} catch (PortalException) {
|
||
// biarkan kosong; pesan tampil saat filter diubah
|
||
}
|
||
}
|
||
|
||
// Laporan dengan 'detail' (kolom modal Lihat) mendapat kolom Aksi berisi tombol Lihat per baris.
|
||
$detail = $definition['detail'] ?? [];
|
||
|
||
return view('operator.satu.remote-list', [
|
||
// Kolom katalog laporan kosong; diisi label kolom hasil (+ 'Aksi' bila ada modal rincian) untuk remote-list.
|
||
'page' => ['columns' => [...array_column($data['columns'], 'label'), ...($detail !== [] ? ['Aksi'] : [])]] + $page,
|
||
'viewable' => $detail !== [],
|
||
'detailColumns' => $detail,
|
||
'crumbs' => ['Beranda' => route(auth()->user()->role->dashboardRoute())] + array_fill_keys(Catalog::trail($slug), null) + [$page['title'] => null],
|
||
// '' (bukan null) = tanpa catatan; null membuat bingkai memakai catatan prototipe bawaannya, padahal ini data asli
|
||
'note' => trim(($definition['note'] ?? '').($errors === [] ? '' : ' Lengkapi filter yang wajib diisi ('.implode(', ', array_map(fn (array $p): string => $p['label'], array_filter($params, fn (array $p): bool => isset($errors[$p['name']])))).') untuk menampilkan data.')) ?: '',
|
||
'empty' => ['icon' => 'document-chart-bar', 'title' => 'Belum ada data', 'description' => 'Data tampil setelah tabel sumbernya terisi.'],
|
||
'url' => route('operator.laporan.data', $slug),
|
||
'filters' => $filters,
|
||
// Kolom dinamis: kepala tabel mengikuti kolom hasil (JSON) agar laporan tanpa data awal tetap menampilkan kolom begitu filter terisi.
|
||
'columns' => [],
|
||
'perPage' => self::PER_PAGE,
|
||
'selectable' => false,
|
||
// Kotak cari: ke sumber bila mengenal q, selain itu saringan generik atas kolom hasil; disembunyikan hanya bila laporan
|
||
// punya parameter lain bernama q.
|
||
'searchable' => (bool) ($definition['search'] ?? false) || ! self::hasParam($definition, 'q'),
|
||
'searchPlaceholder' => $definition['searchHint'] ?? null,
|
||
'barLinks' => [['label' => self::downloadLabel($definition), 'variant' => self::downloadVariant($definition), 'href' => route('operator.laporan.unduh', $slug), 'icon' => 'arrow-down-tray', 'withFilters' => true]],
|
||
'data' => $data,
|
||
]);
|
||
}
|
||
|
||
/** Format unduhan laporan: 'xlsx' bila definisinya meminta ('export' => 'xlsx'), selain itu CSV. */
|
||
private static function exportFormat(array $definition): string
|
||
{
|
||
return ($definition['export'] ?? 'csv') === 'xlsx' ? 'xlsx' : 'csv';
|
||
}
|
||
|
||
/** Label tombol unduh menurut format. */
|
||
private static function downloadLabel(array $definition): string
|
||
{
|
||
return self::exportFormat($definition) === 'xlsx' ? 'Unduh (Excel)' : 'Unduh (CSV)';
|
||
}
|
||
|
||
/**
|
||
* Excel dibangun seluruhnya di memori (PhpSpreadsheet), tidak dialirkan seperti CSV: sekitar 130 MB untuk 9 ribu baris
|
||
* × 7 kolom, sekitar 390 MB dan 17 detik untuk 50 ribu baris. Batas bawaan PHP (128 MB, 30 detik) tidak cukup, jadi
|
||
* dinaikkan hanya selama permintaan unduh ini; pemakaian sebenarnya tetap mengikuti besar laporan.
|
||
*/
|
||
private static function raiseExportLimits(): void
|
||
{
|
||
$limit = (string) ini_get('memory_limit');
|
||
if ($limit !== '-1' && ini_parse_quantity($limit) < self::XLSX_MEMORY) {
|
||
ini_set('memory_limit', (string) self::XLSX_MEMORY);
|
||
}
|
||
set_time_limit(self::XLSX_SECONDS);
|
||
}
|
||
|
||
/** Varian tombol unduh: tosca untuk Excel, sekunder untuk CSV. */
|
||
private static function downloadVariant(array $definition): string
|
||
{
|
||
return self::exportFormat($definition) === 'xlsx' ? 'teal' : 'secondary';
|
||
}
|
||
|
||
public function download(Request $request, string $slug): StreamedResponse|BinaryFileResponse|RedirectResponse
|
||
{
|
||
[$source, $context, $page, $definition] = $this->prepare($request, $slug);
|
||
[$values, $errors] = $this->parse($request, $definition['params'], true);
|
||
if ($errors !== []) {
|
||
return redirect()->route('operator.halaman', [$slug] + $this->queryString($request));
|
||
}
|
||
|
||
// Kata cari di kotak cari ikut berlaku, agar unduhan sama dengan yang tampil di tabel.
|
||
$filterQ = $this->searchTerm($request, $definition, $values);
|
||
|
||
try {
|
||
$result = $source->run($slug, $values, $context, self::DOWNLOAD);
|
||
} catch (PortalException $e) {
|
||
return redirect()->route('operator.halaman', [$slug] + $this->queryString($request));
|
||
}
|
||
|
||
$rows = $filterQ === null ? $result->markedRows() : self::matching($result->markedRows(), $filterQ);
|
||
$name = $slug.'-'.now()->format('Ymd-His');
|
||
|
||
if (self::exportFormat($definition) === 'xlsx') {
|
||
self::raiseExportLimits();
|
||
|
||
return Excel::download(new ReportExport($page['title'], $result->columns, $rows), $name.'.xlsx', ExcelWriter::XLSX, ['Content-Type' => self::XLSX_MIME]);
|
||
}
|
||
|
||
return response()->streamDownload(function () use ($result, $rows): void {
|
||
$out = fopen('php://output', 'w');
|
||
fwrite($out, "\xEF\xBB\xBF"); // BOM agar Excel membaca UTF-8
|
||
fputcsv($out, array_column($result->columns, 'label'), ',', '"', '\\');
|
||
foreach ($rows as $row) {
|
||
fputcsv($out, array_map(fn (array $c): mixed => $row[$c['key']] ?? '', $result->columns), ',', '"', '\\');
|
||
}
|
||
fclose($out);
|
||
}, $name.'.csv', ['Content-Type' => 'text/csv; charset=UTF-8']);
|
||
}
|
||
|
||
public function print(Request $request, string $slug): View|RedirectResponse
|
||
{
|
||
[$source, $context, $page, $definition] = $this->prepare($request, $slug);
|
||
[$values, $errors] = $this->parse($request, $definition['params'], true);
|
||
if ($errors !== []) {
|
||
return redirect()->route('operator.halaman', [$slug] + $this->queryString($request));
|
||
}
|
||
|
||
try {
|
||
$result = $source->run($slug, $values, $context, self::PRINT);
|
||
} catch (PortalException $e) {
|
||
return redirect()->route('operator.halaman', [$slug] + $this->queryString($request));
|
||
}
|
||
|
||
return view('operator.laporan-cetak', [
|
||
'title' => $page['title'],
|
||
'result' => $result,
|
||
'kop' => (bool) ($values['kop'] ?? true),
|
||
'downloadLabel' => self::downloadLabel($definition),
|
||
'parameters' => $this->describe($definition['params'], $values),
|
||
'operator' => $request->user()->username,
|
||
]);
|
||
}
|
||
|
||
/**
|
||
* Penjaga akun dan definisi: akun DB lama dan slug terdaftar; kop (Gunakan KOP) ditambahkan di akhir parameter.
|
||
*
|
||
* @return array{0: ReportSource, 1: ReportContext, 2: array<string, mixed>, 3: array<string, mixed>}
|
||
*/
|
||
private function prepare(Request $request, string $slug): array
|
||
{
|
||
abort_unless($request->user() instanceof Account, 404);
|
||
$source = ReportRegistry::sourceFor($slug) ?? abort(404);
|
||
$page = Catalog::page($slug) ?? abort(404);
|
||
|
||
$programs = $this->overview->programs((int) $request->user()->getKey());
|
||
$context = new ReportContext((int) $request->user()->getKey(), (string) $request->user()->username, $programs->keys()->all(), $programs->all());
|
||
|
||
$definition = $source->definition($slug, $context);
|
||
$definition['params'][] = ['name' => 'kop', 'label' => 'Gunakan KOP', 'type' => 'check', 'default' => true];
|
||
|
||
return [$source, $context, $page, $definition];
|
||
}
|
||
|
||
/**
|
||
* Baca parameter dari query: pilihan dicocokkan ke opsi, teks dipangkas, angka dan tanggal diperiksa.
|
||
* Kotak centang yang tidak dikirim berarti salah; sebelum ada query nilai awalnya dipakai.
|
||
*
|
||
* @param list<array<string, mixed>> $params
|
||
* @return array{0: array<string, mixed>, 1: array<string, string>}
|
||
*/
|
||
private function parse(Request $request, array $params, bool $submitted): array
|
||
{
|
||
$values = [];
|
||
$errors = [];
|
||
|
||
foreach ($params as $p) {
|
||
$name = $p['name'];
|
||
$label = $p['label'];
|
||
$raw = $request->query($name);
|
||
$raw = is_string($raw) ? trim($raw) : null;
|
||
|
||
if ($p['type'] === 'check') {
|
||
$values[$name] = $submitted ? ($raw !== null && $raw !== '' && $raw !== '0') : (bool) ($p['default'] ?? false);
|
||
|
||
continue;
|
||
}
|
||
|
||
if (($raw === null || $raw === '') && ! $submitted && isset($p['default'])) {
|
||
$raw = (string) $p['default'];
|
||
}
|
||
|
||
if ($raw === null || $raw === '') {
|
||
$values[$name] = null;
|
||
if ($p['required'] ?? false) {
|
||
$errors[$name] = "{$label} wajib diisi.";
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
$values[$name] = match ($p['type']) {
|
||
'select' => $this->matchOption($p['options'] ?? [], $raw),
|
||
'number' => preg_match('/^-?\d{1,9}$/', $raw) ? (int) $raw : null,
|
||
'date' => ($d = \DateTimeImmutable::createFromFormat('!Y-m-d', $raw)) && $d->format('Y-m-d') === $raw ? $raw : null,
|
||
default => mb_substr($raw, 0, 100),
|
||
};
|
||
|
||
if ($values[$name] === null) {
|
||
$errors[$name] = "{$label} tidak valid.";
|
||
}
|
||
}
|
||
|
||
return [$values, $errors];
|
||
}
|
||
|
||
/** @param array<int|string, string> $options */
|
||
private function matchOption(array $options, string $raw): int|string|null
|
||
{
|
||
foreach ($options as $key => $label) {
|
||
if ((string) $key === $raw) {
|
||
return $key;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* Nilai awal formulir untuk klien: teks/angka/pilihan sebagai string ('' bila kosong), kotak centang sebagai bool.
|
||
*
|
||
* @param list<array<string, mixed>> $params
|
||
* @param array<string, mixed> $values
|
||
* @return array<string, string|bool>
|
||
*/
|
||
private function clientValues(array $params, array $values): array
|
||
{
|
||
$out = [];
|
||
foreach ($params as $p) {
|
||
$value = $values[$p['name']] ?? null;
|
||
$out[$p['name']] = $p['type'] === 'check' ? (bool) $value : ($value === null ? '' : (string) $value);
|
||
}
|
||
|
||
return $out;
|
||
}
|
||
|
||
/**
|
||
* Ringkasan parameter yang terisi untuk halaman cetak: label => nilai tampil.
|
||
*
|
||
* @param list<array<string, mixed>> $params
|
||
* @param array<string, mixed> $values
|
||
* @return array<string, string>
|
||
*/
|
||
private function describe(array $params, array $values): array
|
||
{
|
||
$out = [];
|
||
foreach ($params as $p) {
|
||
$value = $values[$p['name']] ?? null;
|
||
if ($p['type'] === 'check' || $value === null || $value === '') {
|
||
continue;
|
||
}
|
||
$out[$p['label']] = $p['type'] === 'select' ? (string) ($p['options'][$value] ?? $value) : (string) $value;
|
||
}
|
||
|
||
return $out;
|
||
}
|
||
|
||
/** Query laporan (string saja), untuk pengalihan kembali ke halaman. @return array<string, string> */
|
||
private function queryString(Request $request): array
|
||
{
|
||
return collect($request->query())->filter(fn (mixed $v): bool => is_string($v))->all();
|
||
}
|
||
}
|