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; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $input = Input::all(); $thumb = ''; if (isset($input['thumb'])) { $thumb = $input['thumb']; } $product = $this->productServices->update($id, $input['name'], $input['price'], $input['active'], $thumb, $input['content']); if (!$product) { return $this->respondNotFound('Product does not exist'); } $this->productRepository->update($product); return $this->respond(['data' => $this->transform($product)]); }