/** * Create a paginator default use adapter PaginatorQueryBuilder, * show 30 rows by page starting from $page * * @return array the conatainer object... */ public function paginator($query, $adapter = null) { $page = isset($_GET['page']) ? (int) $_GET['page'] : $this->numberPage; $perPage = isset($_GET['perPage']) ? (int) $_GET['perPage'] : $this->perPage; $builder = ModelBase::modelQuery($query); if (is_null($adapter)) { $paginator = new PaginatorQueryBuilder(['builder' => $builder, 'limit' => $perPage, 'page' => $page]); } else { $paginator = new PaginatorNativeArray(['data' => $builder->getQuery()->execute()->toArray(), 'limit' => $perPage, 'page' => $page]); } return $paginator; }