/** * Display a listing of the resource. * * @return Response */ public function index($category) { // We retrieve the category $item = Category::getByCode($category); // If the category does not exist we throw a 404 message if (!$item) { abort(404); } // We send everything to the view return view('category', ['category' => $item, 'products' => $item->products]); }
/** * Display a listing of the resource. * * @return Response */ public function index($category, $product, $product_id) { // We retrieve the category $category = Category::getByCode($category); // If the category does not exist we throw a 404 message if (!$category) { abort(404); } // We retrieve the category $product = Product::find($product_id); // If the category does not exist we throw a 404 message if (!$product) { abort(404); } // We send everything to the view return view('product', ['category' => $category, 'product' => $product]); }