model = $model; } public function total(): int { return $this->model ->nonEmptyQueue() ->nonReserved() ->count(); } public function showJobs(): LengthAwarePaginator { $currentPage = LengthAwarePaginator::resolveCurrentPage(); $sanitizedPage = $currentPage - 1; $offsetRows = $this->perPage * $sanitizedPage; $query = $this->model ->nonEmptyQueue() ->nonReserved(); $total = $query->count(); $data = $query ->skip($offsetRows) ->take($this->perPage) ->get(); return new LengthAwarePaginator( $this->getOutput($data), $total, $this->perPage ); } protected function getOutput(Collection $data) { if ($this->outputFormat == self::OUTPUT_CLI) { return CLIJobResource::collection($data); } return HttpJobResource::collection($data); } }