/**
  * Show the form for editing the specified product.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $product = $this->productRepository->findById($id);
     $categories_list = $this->categoryRepository->getParentsAndChildrenList();
     //Category::lists('name', 'id')->all();
     $tags_list = Tag::lists('name', 'id')->all();
     $selected_categories = $product->categories()->select('categories.id AS id')->lists('id')->all();
     $selected_tags = $product->tags()->select('tags.id AS id')->lists('id')->all();
     return View('admin.products.edit')->with(compact('product', 'categories_list', 'tags_list', 'selected_categories', 'selected_tags'));
 }
 /**
  * Handle the command.
  *
  * @param  SaveOrderCommand  $command
  * @return void
  */
 public function handle(SaveOrderCommand $command)
 {
     $this->orderRepository->save($command->input);
     $lastOrderId = $this->orderRepository->findLastSavedId();
     foreach ($command->orderItems as $id => $amount) {
         $orderItemName = $this->productRepository->findById($id)->name;
         $this->orderItemRepository->save($orderItemName, $amount, $lastOrderId);
     }
     $order = $this->orderRepository->findById($lastOrderId);
     Mail::send('emails.orderinfo', ['order' => $order], function ($m) use($order) {
         $m->to($order->email, $order->billing_name)->subject('Your Order Information');
     });
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  * @param ProductRepository $products
  * @param SupplierRepository $suppliers
  * @param VatRateRepository $vat_rates
  * @return Response
  */
 public function edit($id, ProductRepository $products, SupplierRepository $suppliers, VatRateRepository $vat_rates)
 {
     try {
         $product = $products->findById($id);
         return view('products.edit')->with('model', $product)->with('suppliers', $suppliers->all())->with('vat_rates', $vat_rates->all());
     } catch (ModelNotFoundException $e) {
         flash() - warning(trans('products.not_found'));
         return redirect()->route('product.index');
     }
 }
예제 #5
0
 /**
  * Add product to cart
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function add(Request $request, ProductRepository $productRepository)
 {
     if ($request->ajax()) {
         $productId = $request->input('product_id');
         $request->session()->push('products', $productId);
         $productName = $productRepository->findById($productId)->name;
         $numberOfProducts = count($request->session()->get('products'));
         return response()->json([$productId, $numberOfProducts, $productName]);
     }
 }
 /**
  * @param $productId
  * @return array
  */
 private function getPurchasedOptions($productId)
 {
     $product = $this->productRepository->findById($productId);
     $option = $product->option_id ? Option::findOrFail($product->option_id) : null;
     $items = [];
     $total = 0;
     $totalDollar = 0;
     if ($option) {
         $optionItem = ['name' => $option->name, 'price' => $option->price, 'priceDollar' => number_format($option->price / 540, 2)];
         if ($product->option_id == 4) {
             $priceTag = $product->tags->count() ? $product->tags->first()->price : 0;
             $optionItem['price'] = $priceTag;
             $optionItem['priceDollar'] = number_format($option->price / 530, 2);
             $optionItem['name'] .= $product->tags->count() ? ' Etiqueta: ' . $product->tags->first()->name : 'No escogio etiqueta';
         }
         $items[] = $optionItem;
     }
     foreach ($items as $item) {
         $total += $item['price'];
         $totalDollar += $item['priceDollar'];
     }
     return array($product, $items, $total, $totalDollar);
 }
예제 #7
0
 public function showProductImages($id)
 {
     //dd($id);
     $product = $this->productRepository->findById($id);
     return view('products.images', compact('product'));
 }
예제 #8
0
 /**
  * Execute the command.
  *
  * @param ProductRepository $products
  * @return Product
  */
 public function handle(ProductRepository $products)
 {
     $product = $products->findById($this->id);
     $products->destroy($product);
     return $product;
 }