recordsModels = $this->pageList(); return view('excelRecharge.records', $this->resultData()); } private function resultData() { return [ 'page' => $this->page(), 'pageList' => $this->recordsModels ]; } private function page() { return PaginationHelper::show($this->recordsModels->total(), $this->recordsModels->currentPage(), $this->recordsModels->perPage()); } /** * @return RecordsModel */ private function pageList() { $records = RecordsModel::orderBy('created_at', 'desc'); return $records->paginate('', ['*'], '', $this->pageParam()); } /** * @return int */ private function pageParam() { return (int)request()->page ?: 1; } }