Created
December 9, 2016 08:22
-
-
Save yooouuri/e9fd17f1b4b69d63f59cf47127307612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param $id | |
* @param int $page | |
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | |
*/ | |
public function category($id, $page = 1) | |
{ | |
$maxItems = 9; | |
$skip = ($page - 1) * $maxItems; | |
$category = Category::find($id); | |
$categories = DB::table('categories') | |
->where('category_id', $id) | |
->skip($skip) | |
->take($maxItems) | |
->get(); | |
$count = DB::table('categories') | |
->where('category_id', $id) | |
->count(); | |
return view('category', ['id' => $id, 'category' => $category, 'categories' => $categories, 'page' => $page, 'count' => ceil($count / $maxItems)]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment