public function toArray() { if ($this->paginator) { try { $total = $this->total(); } catch (Exception $e) { $total = null; } return ['total' => $total, 'per_page' => $this->listRows(), 'current_page' => $this->currentPage(), 'data' => parent::toArray()]; } else { return parent::toArray(); } }