public function update($id, $name, $price, $active, $thumb, $content) { Assertion::string($name); Assertion::boolean($active); $product = $this->products->productOfId($id); $product->name = $name; $product->slug = Str::slug($name); $product->price = $price; $product->active = $active; if ($thumb) { $product->thumb = $thumb; } $product->content = $content; $this->products->update($product); return $product; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $product = $this->productRepository->productOfId($id); if (!$product) { return $this->respondNotFound('Product does not exist'); } $this->productRepository->delete($product); return $this->respond(['data' => $this->transform($product)]); }