public function post(Request $request)
 {
     $orderItemId = $request->input('orderItemId');
     $orderItem = $this->getOrderItemWithAllData($orderItemId);
     $image = Arr::get($_FILES, 'image');
     $uploadFileDTO = new UploadFileDTO(Arr::get($image, 'name'), Arr::get($image, 'type'), Arr::get($image, 'tmp_name'), Arr::get($image, 'size'));
     if (!is_uploaded_file($uploadFileDTO->getFilePath())) {
         abort(400);
     }
     try {
         $this->dispatch(new CreateAttachmentForOrderItemCommand($uploadFileDTO, $orderItem->id->getHex()));
         $this->flashSuccess('Attachment uploaded.');
     } catch (KommerceException $e) {
         $this->flashError('Unable to upload attachment.');
     }
     return redirect()->route('admin.order.view', ['orderId' => $orderItem->order->id->getHex()]);
 }
 public function post(Request $request)
 {
     $productId = $request->input('productId');
     $product = $this->getProductWithAllData($productId);
     $image = Arr::get($_FILES, 'image');
     $uploadFileDTO = new UploadFileDTO(Arr::get($image, 'name'), Arr::get($image, 'type'), Arr::get($image, 'tmp_name'), Arr::get($image, 'size'));
     if (!is_uploaded_file($uploadFileDTO->getFilePath())) {
         abort(400);
     }
     try {
         $this->dispatch(new CreateImageForProductCommand($uploadFileDTO, $product->id->getHex()));
         $this->flashSuccess('Image uploaded.');
     } catch (KommerceException $e) {
         $this->flashError('Unable to upload image.');
     }
     return redirect()->route('admin.product.images', ['productId' => $product->id->getHex()]);
 }
 private function updateProductDTOFromPost(ProductDTO &$productDTO, array $productValues)
 {
     $unitPrice = (int) floor(Arr::get($productValues, 'unitPrice') * 100);
     $productDTO->name = trim(Arr::get($productValues, 'name'));
     $productDTO->sku = trim(Arr::get($productValues, 'sku'));
     $productDTO->description = trim(Arr::get($productValues, 'description'));
     $productDTO->unitPrice = $unitPrice;
     $productDTO->quantity = Arr::get($productValues, 'quantity');
     $productDTO->shippingWeight = Arr::get($productValues, 'shippingWeight');
     $productDTO->isInventoryRequired = Arr::get($productValues, 'isInventoryRequired', false);
     $productDTO->isPriceVisible = Arr::get($productValues, 'isPriceVisible', false);
     $productDTO->isActive = Arr::get($productValues, 'isActive', false);
     $productDTO->isVisible = Arr::get($productValues, 'isVisible', false);
     $productDTO->isTaxable = Arr::get($productValues, 'isTaxable', false);
     $productDTO->isShippable = Arr::get($productValues, 'isShippable', false);
     $productDTO->isShippable = Arr::get($productValues, 'isShippable', false);
     $productDTO->areAttachmentsEnabled = Arr::get($productValues, 'areAttachmentsEnabled', false);
 }
 public function post(Request $request)
 {
     $userId = '';
     // TODO: Grab authenticated userId
     $productId = $request->input('productId');
     $product = $this->getProduct($productId);
     $image = Arr::get($_FILES, 'image');
     $uploadFileDTO = new UploadFileDTO(Arr::get($image, 'name'), Arr::get($image, 'type'), Arr::get($image, 'tmp_name'), Arr::get($image, 'size'));
     dd(get_defined_vars());
     if (!is_uploaded_file($uploadFileDTO->getFilePath())) {
         abort(400);
     }
     try {
         $this->dispatch(new CreateAttachmentForUserProductCommand($uploadFileDTO, $userId, $product->id->getHex()));
         $this->flashSuccess('Attachment uploaded.');
         return redirect()->route('product.show', ['slug' => $product->slug, 'productId' => $product->id->getHex()]);
     } catch (KommerceException $e) {
         $this->flashError('Unable to upload attachment.');
         return redirect()->route('user.attachment.createForProduct', ['productId' => $product->id->getHex()]);
     }
 }