total = $total; $this->per_page = $per_page; $this->page = $page; $this->last_page = $last_page; $this->items = $items; } public function getTotal() { return $this->total; } /** * @return int */ public function getPerPage() { return $this->per_page; } /** * @return int */ public function getCurrentPage() { return $this->page; } /** * @return int */ public function getLastPage() { return $this->last_page; } /** * @return array */ public function getItems() { return $this->items; } /** * @param null $expand * @param array $fields * @param array $relations * @param array $params * @param string $serializer_type * @return array */ public function toArray($expand = null, array $fields = [], array $relations = [], array $params = [], $serializer_type = SerializerRegistry::SerializerType_Public ) { $items = []; foreach($this->items as $i) { if($i instanceof IEntity) { $i = SerializerRegistry::getInstance()->getSerializer($i)->serialize($expand, $fields, $relations, $params); } $items[] = $i; } return [ 'total' => $this->total, 'per_page' => $this->per_page, 'current_page' => $this->page, 'last_page' => $this->last_page, 'data' => $items, ]; } }