/** * Handle the command. * * @param SaveProduct $command * @return void */ public function handle(SaveProduct $command) { $this->productRepository->save($command->input); $modelNumber = $this->productRepository->findLastSavedModelNumber(); $productId = (int) $this->productRepository->findLastSavedId(); $imageCount = $this->imageRepository->count() + 1; $this->imageRepository->uploadImages($command->input['images'], $modelNumber, $productId, $imageCount); }
/** * Execute the command. * * @param ProductRepository $products * @return Product */ public function handle(ProductRepository $products) { $product = $products->findById($this->id)->fill($this->getProperties()); $products->save($product); $this->saveAttributes($product); return $product; }
/** * Execute the command. * * @param ProductRepository $products * @return Product */ public function handle(ProductRepository $products) { $product = Product::register($this->product_number, $this->description, $this->product_type_id); $products->save($product); return $product; }