示例#1
0
 /**
  * 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>';
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function next()
 {
     return $this->posts->nextPageUrl();
 }