public function category($slug) { $Category = Category::findBySlug($slug); $books = Books::where('category_id', '=', $Category->id)->paginate(12); $categories = Category::all(); return view('books.category', compact('books', 'Category', 'categories')); }
/** * @param $slug * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showSingleCategory($slug) { $categories = Category::with('products')->where('is_active', true)->has('products')->get(); $category = Category::findBySlug($slug); $products = $category->products; return view('frontend.categories.showCategory', compact('categories', 'category', 'products')); }
/** * Display the specified resource. * * @param int $id * * @return Response */ public function show($slug) { //$articles = Category::findBySlug($slug)->articles()->latest()->paginate(8); $page_size = setting('page_size'); $category = Category::findBySlug($slug); $articles = \App\Article::with('tags', 'category')->whereHas('category', function ($query) use($slug) { $query->whereSlug($slug); })->latest()->paginate($page_size); return view('home.categories.show', compact('articles', 'category')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $cate = Category::findBySlug($id); $cate->delete(); return redirect()->back(); }
/** * Display the specified resource. * * @param int $id * * @return Response */ public function show($slug) { $category = Category::findBySlug($slug); return view('categories.show', compact('category')); }