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); } } }