/** * Move the page. * * @param int $id * @param 'before'|'after' $dir * * @return Response */ protected function move($id, $dir) { $category = $this->categoryRepository->findById($id); $response = Redirect()->route('categories'); if (!$category->isRoot()) { try { $dir === 'before' ? $category->moveLeft() : $category->moveRight(); Flash('Category moved'); return $response; } catch (moveExp $ex) { dd('error'); Flash('The category did not move'); return $response; } } Flash('The category did not move'); return $response; }
public function index($categoryId, ProductRepository $productRepository, CategoryRepository $categoryRepository) { $categoryName = $categoryRepository->findById($categoryId)->name; $products = $productRepository->findByCategory($categoryId); return view('categories.products.index', compact('products', 'categoryName')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $category = $this->categoryRepository->findById($id); return view('categories.edit', compact('category')); }