/**
  * Store a newly created Product in storage.
  *
  * @param CreateProductRequest $request
  *
  * @return Response
  */
 public function store(CreateProductRequest $request)
 {
     $input = $request->all();
     $product = $this->productRepository->create($input);
     Flash::success('Product saved successfully.');
     return redirect()->back();
 }
 /**
  * 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;
 }
 /**
  * Handle the command.
  *
  * @param  UpdateProduct $command
  * @return void
  */
 public function handle(UpdateProduct $command)
 {
     $this->productRepository->update($command->productId, $command->input);
     $modelNumber = $this->productRepository->findLastSavedModelNumber();
     $imageCount = $this->imageRepository->count() + 1;
     $this->imageRepository->uploadImages($command->input['images'], $modelNumber, $command->productId, $imageCount);
 }
 /**
  * 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]);
     }
 }
Beispiel #5
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');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $tu = $this->userRepository->getTotal();
     $tp = $this->productRepository->getTotal();
     $tc = $this->categoryRepository->getTotal();
     $tt = $this->tagRepository->getTotal();
     $op = Option::count();
     $pm = $this->paymentRepository->getTotal();
     return View('admin.dashboard.index')->with(compact('tu', 'tp', 'tc', 'tt', 'op', 'pm'));
 }
 /**
  * Put a product visible or invisible
  *
  * @param $id
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function update($id, Request $request)
 {
     $product = $this->productRepository->updateVisibility($id, $request->get('visible'));
     //        if($request->get('visible')) {
     //            $product = $this->productRepository->updateVisibility($id, true);
     //        } else {
     //            $product = $this->productRepository->updateVisibility($id, false);
     //        }
     return response()->json($product, 200);
 }
 /**
  * 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');
     });
 }
 public function actionCategory($categoryId)
 {
     $category = ProductCategory::findOne($categoryId);
     if (empty($category)) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     if ($this->isAjax()) {
         $model = new Recipe();
         $model->productCategoryId = $categoryId;
         return $this->renderPartial('@app/views/partials/_category-ingredients-dropdown-list', ['model' => $model, 'form' => ActiveForm::begin()]);
     } else {
         $params = Yii::$app->request->queryParams;
         $params['categoryId'] = $categoryId;
         $searchModel = new ProductRepository();
         $dataProvider = $searchModel->search($params);
         return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'categoryName' => $category->name]);
     }
 }
 public function approve($id)
 {
     $product = $this->productRepository->findWithoutFail($id);
     if (empty($product)) {
         Flash::error('Tracking not found');
         return back();
     }
     $this->productRepository->update(["state" => "Approved"], $id);
     Flash::success('Product approved!');
     return back();
 }
 /**
  * Remove multiple products from storage.
  * DELETE /products/{id}
  *
  * @internal param int $chk_activity (array of ids)
  * @param Request $request
  * @return Response
  */
 public function option_multiple(Request $request)
 {
     $products_id = $request->input('chk_product');
     $action = $request->input('select_action');
     foreach ($products_id as $id) {
         if ($action == "active") {
             $this->productRepository->update_state($id, 1);
         } elseif ($action == "inactive") {
             $this->productRepository->update_state($id, 0);
         }
         /*elseif($action == "delete")
           $this->productRepository->destroy($id);*/
     }
     return Redirect()->route('products');
 }
 /**
  * @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);
 }
 public function index($categoryId, ProductRepository $productRepository, CategoryRepository $categoryRepository)
 {
     $categoryName = $categoryRepository->findById($categoryId)->name;
     $products = $productRepository->findByCategory($categoryId);
     return view('categories.products.index', compact('products', 'categoryName'));
 }
 public function homePage(ProductRepository $products, CategoryRepository $categories)
 {
     return view('admin.main')->with('products', $products->paginate())->with('cats', $categories->all(['name']))->with('homegrids', HomeGrid::all());
 }
 /**
  * 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;
 }
 public function index(ProductRepository $productRepository)
 {
     $products = $productRepository->all();
     return view('pages.index', compact('products'));
 }
 public function show()
 {
     $designer = app('post');
     $products = $this->products->getProductsByDesigner($designer);
     return view('pages.designer', ['designer' => $designer, 'products' => $products]);
 }
 public function show($product)
 {
     $product = $this->products->findByName($product);
     $product = $this->prepareProductForDisplay($product);
     return view('pages.products.product', ['product' => $product]);
 }
 /**
  * Execute the command.
  *
  * @param ProductRepository $products
  * @return Product
  */
 public function handle(ProductRepository $products)
 {
     $product = $products->findById($this->id);
     $products->destroy($product);
     return $product;
 }
 public function showProductImages($id)
 {
     //dd($id);
     $product = $this->productRepository->findById($id);
     return view('products.images', compact('product'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|max:255', 'quantity' => 'required', 'item_price' => 'required']);
     $this->products->update($id, $request->input('name'), $request->input('quantity'), $request->input('item_price'));
     return redirect('/');
 }
 /**
  * Execute the command.
  *
  * @param ProductRepository $products
  * @return Paginator
  */
 public function handle(ProductRepository $products)
 {
     return $products->query($this->query);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function Home()
 {
     //$featured = $this->productRepository->getFeaturedBanner();
     $products = $this->productRepository->getFeatured();
     return view('pages.index')->with(compact('products'));
 }
 /**
  * Handle the command.
  *
  * @internal param ImportFromSpreadsheet $command
  */
 public function handle()
 {
     $this->categoryRepository->saveFromList($this->excelImportRepository->getColumn('category'));
     $this->manufacturerRepository->saveFromList($this->excelImportRepository->getColumn('manufacturer'));
     $this->productRepository->saveFromList($this->excelImportRepository->getAllColumns());
 }