Penambahn P1 Dev

This commit is contained in:
Ariyutta
2026-10-20 10:24:22 +07:00
parent 8418a63fc0
commit ee0e6deacc
43 changed files with 5406 additions and 44 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\DataTables;
use Exception;
use Illuminate\Http\JsonResponse;
use Yajra\DataTables\CollectionDataTable;
/** P1 searches and sorts scalar columns; nested payment histories are display data. */
class P1CollectionDataTable extends CollectionDataTable
{
protected function defaultOrdering(): void
{
$criteria = $this->request->orderableColumns();
if ($criteria !== []) {
// Do not flatten and rebuild every employee's entire payment history to sort names.
$this->collection = $this->collection->sort($this->getSorter($criteria));
}
}
public function make(bool $mDataSupport = true): JsonResponse
{
try {
$this->validateMinLengthSearch();
$this->totalRecords = $this->totalCount();
if ($this->totalRecords) {
$this->filterRecords();
$this->ordering();
$this->paginate();
// Format and escape only the requested page, including its nested detail data.
$results = $this->results();
$processed = $this->processResults($results, $mDataSupport);
$this->collection = collect($this->transform($results, $processed));
}
return $this->render($this->collection->values()->all());
} catch (Exception $exception) {
return $this->errorResponse($exception);
}
}
}