request->input('limit', 20); $orderList = $this->orderModel ->where('user_id', $this->userId) ->when($this->request->input('status'), function ($query) { $query->where('status', $this->request->input('status')); }) ->orderByDesc('id') ->paginate($limit) ->toArray(); if (!empty($orderList['data'])) { $this->buildData($orderList['data']); } } private function buildData(array &$orderList) { // foreach ($orderList as &$order) { // // } } }