示例#1
0
 /**
  * Returns products on a specific category page
  *
  * @param  \October\Rain\Database\Builder   $query
  * @param  \Bedard\Shop\Models\Category     $category
  * @param  integer                          $page
  * @return \October\Rain\Database\Builder
  */
 public function scopeOnPage($query, Category $category, $page)
 {
     // For falsey page sizes, don't paginate
     if (!($size = $category->getPageSize())) {
         return $query;
     }
     // Count from zero
     $page = $page > 0 ? $page - 1 : 0;
     return $query->skip($page * $size)->take($size);
 }