function categorize($package, $category) { $categories = new Categories($this->channel); if (!$categories->exists($category)) { echo 'That category doesn\'t exist yet. Use add-category first' . PHP_EOL; } $categories->linkPackageToCategory($package, $category); $rcat = new REST\Category($this->restpath, $this->channel, 'rest/', $categories); $rcat->savePackages($category); $rcat->savePackagesInfo($category); }
/** * Remove the specified category from database. * * @param int $id * @return Response */ public function destroy($id) { $category = Categories::find($id); $check = new Categories(); $error = "You can not delete this category because some products depend on it"; if ($check->exists($id) == true) { return Redirect::to('categories')->with('error', $error); } else { $category->delete(); } // redirect return Redirect::to('categories'); }