/** * todo make a better html paginator * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $collection * @return string */ function paginate(\Illuminate\Contracts\Pagination\LengthAwarePaginator $collection) { $current = $collection->currentPage(); $per = $collection->perPage(); $count = $collection->count(); $from = $current * $per; $to = $from + $count; $html = ''; // "From {$from} to {$to}"; $previous = $current > 1 ? $collection->url("?page=" . ($current - 1)) : false; $next = $collection->hasMorePages() ? $collection->nextPageUrl() : false; if ($previous) { $html .= '<li><a href="' . $previous . '">prev</a></li>'; } if ($next) { $html .= '<li><a href="' . $next . '">next</a></li>'; } return '<ul>' . $html . '</ul>'; }
/** * Get the url for the given page. * * @param int $page * * @return string */ public function getUrl($page) { return $this->paginator->url($page); }
/** * {@inheritdoc} */ public function canonicalUrl() { return $this->posts->url($this->posts->currentPage()); }