recordsModels = $this->pageList(); return view('excelRecharge.detail', $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 DetailModel */ private function pageList() { $records = DetailModel::with('member'); $rechargeId = $this->rechargeIdParam(); if ($rechargeId) { $records->where('recharge_id', $rechargeId); } return $records->orderBy('created_at', 'desc') ->orderBy('id', 'desc') ->paginate('', ['*'], '', $this->pageParam()); } /** * @return int */ private function pageParam() { return (int)request()->page ?: 1; } /** * @return int */ private function rechargeIdParam() { return (int)request()->recharge_id ?: 1; } }