get()->sortBy('position'); return view('category.categories', ['categories' => $categories]); } /** * Show All Torrents Within A Category. * * @param $slug * @param $id * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function category($slug, $id) { $user = auth()->user(); $category = Category::select(['id', 'name', 'slug'])->findOrFail($id); $torrents = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->where('category_id', '=', $id)->orderBy('sticky', 'desc')->latest()->paginate(25); $personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first(); return view('category.category', [ 'torrents' => $torrents, 'user' => $user, 'category' => $category, 'personal_freeleech' => $personal_freeleech, ]); } }