public function action_view() { $perPage = 21; $categoryAlias = $this->request->param('category'); //$this->request->param('id'); if (!$categoryAlias) { throw new NotFoundException(); } $category = $this->model->loadCategoryByAlias($categoryAlias); if ($category instanceof \App\Model\Category) { $helper = $this->pixie->view_helper(); $this->pageTitle = trim($category->meta_title) ? $category->meta_title : $category->getPrintName(); $this->pageDescription = trim($category->meta_desc) ? $category->meta_desc : $helper->excerpt($category->description, 300); $this->pageKeywords = $category->meta_keywords; $this->view->categoryName = $category->getPrintName(); $this->view->h1 = trim($category->h1) ? $category->h1 : $category->getPrintName(); $this->view->description = $category->description; $page = $this->request->get('page', 1); $productModel = new Product($this->pixie); $productModel->prepareForCategory($category); /** @var ORM $pager */ $pager = $this->pixie->paginate->orm($productModel, $page, $perPage); $this->view->products = $pager->current_items()->as_array(); $this->view->pager = $pager; $this->view->subview = 'category/category'; $this->view->breadcrumbs = $this->getBreadcrumbs($category); $this->view->categoryID = $category->id(); $this->view->category = $category; } else { throw new NotFoundException(); } }
public function formSucceeded(Form $form, $values) { // pro odchytavani chyb $error = null; // ostatni akce $product = new Model\Product($this->database); $values['id_user'] = $this->id_user; $imgs = $values['img']; unset($values['img']); // add / edit if ($values['id'] == null) { // add $p = $product->add($values); $product_id = $p->id; $form->getPresenter()->flashMessage('Produkt byl úspěšně vytvořen.'); } else { // edit $error = $product->update($values, $values['id']); $product_id = $values['id']; $form->getPresenter()->flashMessage('Produkt byl úspěšně upraven.'); } if ($error == null) { // nahrani fotek k produktu if ($imgs != null) { $photo_manager = new Model\Photo($this->database); $photo_manager->uploadProductPhotos($imgs, $product_id); } // presmerovani $form->getPresenter()->redirect('Homepage:product', $product_id); } else { $form->addError($error); } }
/** * @Vuln\Description("View used: home/home") */ public function action_index() { $mostPopularProductsCount = 3; $bestSellingProductsCount = 3; $specialOffersCount = 3; $otherCustomerProductCount = 4; // Amount of products in the bottom of the page $randomProductsCount = 4; // Count of reviews after each product section. $productSectionReviewCount = 3; $product = new Product($this->pixie); $special_offers = new SpecialOffers($this->pixie); $review = new Review($this->pixie); //$this->view->topViewedProducts = $product->getRandomProducts($this->topViewedCount); $visitedProductIds = $this->request->cookieWrap('visited_products'); $this->view->rnd_products = $product->getRndProduct(self::COUNT_RND_PRODUCTS); $this->view->relatedToVisitedProducts = $product->getVisitedProducts($visitedProductIds); //$product->getRandomProducts($this->relatedToVisitedCount); $this->view->bestChoiceProducts = $product->getRandomProducts($this->bestChoiceCount); $this->view->mostPopularProducts = $product->getRandomProducts($mostPopularProductsCount); $this->view->bestSellingProducts = $product->getRandomProducts($bestSellingProductsCount); $this->view->randomProducts = $product->getRandomProducts($randomProductsCount); $this->view->special_offers = $special_offers->getRandomOffers($specialOffersCount); $this->view->selectedReviews = $review->getRandomReviews($this->reviewsCount); $this->view->otherCustomersProducts = $product->getRandomProducts($otherCustomerProductCount); $this->view->productSections = array('related_to_viewed' => array('title' => 'Related to Visited', 'products' => $this->view->relatedToVisitedProducts, 'reviews' => count($this->view->relatedToVisitedProducts) ? $review->getRandomReviews($productSectionReviewCount) : array()), 'best_choice' => array('title' => 'Best Choice', 'products' => $this->view->bestChoiceProducts, 'reviews' => count($this->view->bestChoiceProducts) ? $review->getRandomReviews($productSectionReviewCount) : array()), 'random' => array('title' => "", 'products' => $this->view->randomProducts)); $this->view->topProductBlocks = array('most_popular' => array('title' => "Top {$bestSellingProductsCount} most popular", 'products' => $this->view->mostPopularProducts), 'best_selling' => array('title' => "Top {$bestSellingProductsCount} best selling", 'products' => $this->view->bestSellingProducts)); $this->view->common_path = $this->common_path; $this->view->subview = 'home/home'; $this->view->message = "Index page"; }
public function apply($productId) { $product = Product::find($productId); $preferedPartner = $product->preferedPartner->id; print_r($preferedPartner); exit; }
/** * 创建或更新内容 * * @param App\Model\Product $product * @param array $inputs * @param string $type * @param string|int $user_id * @return App\Model\Product */ private function saveProduct($product, $inputs, $user_id = '1') { $product->name = e($inputs['name']); $product->body = e($inputs['body']); $product->thumb = e($inputs['thumb']); $product->sort = e($inputs['sort']); $product->price = e($inputs['price']); $product->spec = e($inputs['spec']); if (array_key_exists('status', $inputs)) { $product->status = e($inputs['status']); } if ($user_id) { $product->ad_id = $user_id; } $product->save(); return $product; }
/** * [paginationAction description] * @return [type] [description] * this is using ajax but it not good for seo */ public function paginationAction() { header('Content-Type: application/json'); //goi ham phan trang trong maintroller $t = $this->getPostData(); $page = $t['id']; //$html = $this->pagination($page); // ================================== goi ham phan trang ======= $totalpage = ""; //tinh xem minh co khoan bao nhieu page $per_page = 3; //tong so item tren mot trang $record = count(Product::getAll()); //tong so hang cua csdl if ($record > $per_page) { $totalpage = ceil($record / $per_page); } else { $totalpage = 1; } $start = ($page - 1) * $per_page; //tinh so dong bat dau trong co so du lieu tu page nhap vao $end_page = $totalpage - 1; $productpage = Product::getPaginate($start, $per_page); //var_dump($productpage); //hien thi data $data = ""; foreach ($productpage as $p) { $data .= '<li>'; $data .= '<div class="product-item">'; $data .= '<div class="img-feature">'; $data .= '<img src=' . $p["feature_img"] . ' width="200" height="250" alt="">'; $data .= '</div>'; $data .= '<div class="desc">'; $data .= "<p>Name:" . $p['name'] . "</p>"; $data .= "<p>Giá:" . $p['price'] . "</p>"; $data .= "<p>Tình trạng:" . $p['qty'] . "</p>"; $data .= "</div>"; $data .= "<span class='BTN'> <a href='#' onclick='addcart(" . $p['id'] . ")'> AddToCart</a></span>"; $data .= "<br> "; $data .= "<span class='BTN'> <a href='../detailpage/" . $p['id'] . "'> Chi tiet</a></span>"; $data .= "</div></li>"; } //hien thi link page: 2 3 4.... $html = ""; for ($i = 1; $i <= $totalpage; $i++) { if ($page == $i) { $html .= "<li class='current'><a href='#' onclick='demo({$i})'> {$i} </a></li>"; } else { $html .= "<li ><a href='#' onclick='demo({$i})'> {$i} </a></li>"; } } // =================================================== return json_encode(array('html' => $html, 'data' => $data)); }
public function deleteAction() { if ($this->getPostData()) { $post = $this->getPostData(); if ($post['token'] == $this->app['session']->get('token')) { Product::deleteProduct($post['id']); $this->app['session']->remove('token'); return $this->redirect('viewproduct'); } } return false; }
public function showHome() { //gets latest post $news = Post::where('is_published', 1)->where('is_active', 1)->where('post_type', 1)->orderBy('updated_at', 'desc')->first(); $job = Post::where('is_published', 1)->where('is_active', 1)->where('post_type', 2)->orderBy('updated_at', 'desc')->first(); $product = Product::where('is_active', 1)->orderby('updated_at', 'desc')->first(); $project = Project::where('is_public', 1)->where('is_active', 1)->orderBy('updated_at', 'desc')->first(); $newsContent = htmlspecialchars_decode($news->content, ENT_NOQUOTES); $news->content = $newsContent; //dd($news); return view('pages.home', ['news' => $news, 'job' => $job, 'product' => $product, 'project' => $project]); }
/** * Get tag list id of this article * * @return mixed */ public function getContentAttribute($content) { $content = unserialize($content); $items = []; foreach ($content as $value) { $product = Product::find($value['index']); $item['name'] = $product->name; $item['number'] = $value['number']; $item['unit'] = $product->getUnit->name; array_push($items, $item); } return $items; }
private function generateProduct($count = 10) { // create simple parameter $propertyType = new PropertyType(); $propertyType->id = 4; $propertyType->name = 'number'; $propertyType->status_id = self::DEFAULT_STATUS_ID; $propertyType->save(); // create a parameter implementation $property = new Property(); $property->name = "Rok výroby"; $property->type_id = $propertyType->id; $property->status_id = self::DEFAULT_STATUS_ID; $property->save(); $partners = Partner::all(); $feeds = Feed::all(); // select brand $brands = Brand::all(); // categories $categories = Category::all(); for ($i = 0; $i < $count; $i++) { $brand = $brands[rand(0, count($brands) - 1)]; $year = rand(2000, 2015); $name = sprintf("%s %s %d", $brand->title, $this->types[$brand->code][0], $year); $ean = EanUtil::getInstance()->generateEan(); $product = new Product(); $product->brand_id = $brand->id; $product->name = $name; $product->status_id = self::DEFAULT_STATUS_ID; $product->ean = $ean; $product->product_id = substr($ean, 0, 6); $product->save(); $propertyYear = new ProductProperty(); $propertyYear->value = "s:4:\"{$year}\""; $propertyYear->status_id = self::DEFAULT_STATUS_ID; $propertyYear->product_id = $product->id; $propertyYear->property_id = $property->id; $propertyYear->save(); $this->generateProductFeedItem($product, $partners, $feeds); $category = $categories[rand(0, count($categories) - 1)]; $productCategory = new Product\ProductCategory(); $productCategory->product_id = $product->id; $productCategory->category_id = $category->id; $productCategory->status_id = self::DEFAULT_STATUS_ID; $productCategory->save(); // $this->generateProductGallery($product); } }
/** * * @param mixed $product * @return type */ public function indexProduct($productId) { $product = Product::find($productId); // check product if (!$product) { logger()->error(sprintf("Product %d not found.", $productId)); return; } logger()->info("Index started"); $indexedProduct = $this->esProduct($product); // print_r($indexedProduct); $params = ["index" => "amanda", "type" => "product", "id" => $product["id"], "body" => $indexedProduct]; $response = $this->esClient->index($params); logger()->info("Finishing indexing", ["id" => $product["id"]]); return $response; }
public function pagination($page) { $totalpage = ""; //tinh xem minh co khoan bao nhieu page $per_page = 3; //tong so item tren mot trang $record = count(Product::getAll()); //tong so hang cua csdl if ($record > $per_page) { $totalpage = ceil($record / $per_page); } else { $totalpage = 1; } $start = ($page - 1) * $per_page; //tinh so dong bat dau trong co so du lieu tu page nhap vao $end_page = $totalpage - 1; $productpage = Product::getPaginate($start, $per_page); // $current = ($start/$per_page) + 1; // $next = $start + $per_page; // $previous = $start - $per_page; // $last = ($page - 1)*$per_page; // if($current >4){ // $start_page = $current -2; // if($page > $current+2) $end_page = $current + 2; // } //hien thi first , previous // if($current > 1){ // $html .= "<li><a> First </a></li>"; // $html .= "<li><a> Previous </a></li>"; // } //hien thi link page: 2 3 4.... $html = ""; for ($i = 1; $i <= $end_page; $i++) { if ($page == $i) { $html .= "<li class='current'><a href='#' onclick='demo({$i})'> {$i} </a></li>"; } else { $html .= "<li ><a href='#' onclick='demo({$i})'> {$i} </a></li>"; } } //hien thi last page va next // if($current < $page){ // $html .= "<li><a> Next </a></li>"; // $html .= "<li><a> Last </a></li>"; // } return $html; }
public function apply($productId) { // find a product $product = \App\Model\Product::find($productId); if (!$product) { // product not found logger()->error(sprintf("Product %d not found.", $productId)); // it should never happen return 0; } // product price $productPrice = $product->price; if ($productPrice) { logger()->debug(sprintf("Found product defined price %f for product %d", $productPrice, $productId)); return $productPrice; } }
public function updateCartAction() { header('Content-Type: application/json'); $t = $this->getPostData(); $getSS = $this->app['session']->get('cart'); $id = $t['id']; $getSS[$id] = abs($t['qty']); $this->app['session']->set('cart', $getSS); // $sum = $this->totalCart(); // var_dump($sum); $sum = 0; $getSS = $this->app['session']->get('cart'); foreach ($getSS as $id => $qty) { $p = Product::getById($id); $sum = $sum + $p[0]['price'] * $qty; } return json_encode(array('qty' => abs($t['qty']), 'sum' => $sum)); }
/** * @param \App\Model\Product $product * @param $category * @return array * @throws \Exception */ public function getPrevAndNextProducts($product, $category) { $productModel = new \App\Model\Product($this->pixie); $productModel->prepareForCategory($category); $productModel->prepare_relations(); $productModel->query->fields('tbl_products.productID'); /** @var Result $result */ $result = $productModel->query->execute(); $ids = $result->as_array(); $prevItem = null; $nextItem = null; foreach ($ids as $key => $row) { if ($row->productID == $product->id()) { if ($ids[$key - 1] && $ids[$key - 1]->productID) { $prevItem = $this->pixie->orm->get('product', $ids[$key - 1]->productID); } if ($ids[$key + 1] && $ids[$key + 1]->productID) { $nextItem = $this->pixie->orm->get('product', $ids[$key + 1]->productID); } break; } } return [$prevItem, $nextItem]; }
public function store(Request $request) { $obj = new helpers(); //echo "<pre>";print_r(Request::all());exit; if (Input::hasFile('image1')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $home_thumb_path = 'uploads/product/home_thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image1')->getClientOriginalExtension(); // getting image extension $fileName1 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image1')->move($destinationPath, $fileName1); // uploading file to given path $obj->createThumbnail($fileName1, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName1, 380, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName1, 109, 89, $destinationPath, $medium); } else { $fileName1 = ''; } if (Input::hasFile('image2')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $home_thumb_path = 'uploads/product/home_thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image2')->getClientOriginalExtension(); // getting image extension $fileName2 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image2')->move($destinationPath, $fileName2); // uploading file to given path $obj->createThumbnail($fileName2, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName2, 380, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName2, 109, 89, $destinationPath, $medium); } else { $fileName2 = ''; } if (Input::hasFile('image3')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $home_thumb_path = 'uploads/product/home_thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image3')->getClientOriginalExtension(); // getting image extension $fileName3 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image3')->move($destinationPath, $fileName3); // uploading file to given path $obj->createThumbnail($fileName3, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName3, 380, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName3, 109, 89, $destinationPath, $medium); } else { $fileName3 = ''; } if (Input::hasFile('image4')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $home_thumb_path = 'uploads/product/home_thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image4')->getClientOriginalExtension(); // getting image extension $fileName4 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image4')->move($destinationPath, $fileName4); // uploading file to given path $obj->createThumbnail($fileName4, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName4, 380, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName4, 109, 89, $destinationPath, $medium); } else { $fileName4 = ''; } if (Input::hasFile('image5')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $home_thumb_path = 'uploads/product/home_thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image5')->getClientOriginalExtension(); // getting image extension $fileName5 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image5')->move($destinationPath, $fileName5); // uploading file to given path $obj->createThumbnail($fileName5, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName5, 380, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName5, 109, 89, $destinationPath, $medium); } else { $fileName5 = ''; } if (Input::hasFile('image6')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $home_thumb_path = 'uploads/product/home_thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image6')->getClientOriginalExtension(); // getting image extension $fileName6 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image6')->move($destinationPath, $fileName6); // uploading file to given path $obj->createThumbnail($fileName6, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName6, 380, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName6, 109, 89, $destinationPath, $medium); } else { $fileName6 = ''; } if (Input::hasFile('label')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('label')->getClientOriginalExtension(); // getting image extension $label = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('label')->move($destinationPath, $label); // uploading file to given path $this->obj->createThumbnail($label, 600, 650, $destinationPath, $thumb_path); $this->obj->createThumbnail($label, 109, 89, $destinationPath, $medium); } else { $label = Request::input('hidden_label'); } $product['product_name'] = Request::input('product_name'); $product['own_product'] = Request::input('own_product'); $product['product_slug'] = $obj->create_slug(Request::input('product_name'), 'products', 'product_slug'); $product['image1'] = $fileName1; $product['image2'] = $fileName2; $product['image3'] = $fileName3; $product['image4'] = $fileName4; $product['image5'] = $fileName5; $product['image6'] = $fileName6; $product['label'] = $label; $product['description1'] = htmlentities(Request::input('description1')); $product['description2'] = htmlentities(Request::input('description2')); $product['description3'] = htmlentities(Request::input('description3')); $product['brandmember_id'] = Request::input('brandmember_id'); $product['tags'] = Request::input('tags'); $product['sku'] = $obj->random_string(9); $product['script_generated'] = '<a href="' . url() . '/product-details/' . $product['product_slug'] . '" style="color: #FFF;background: #78d5e5 none repeat scroll 0% 0%;padding: 10px 20px;font-weight: 400;font-size: 12px;line-height: 25px;text-shadow: none;border: 0px none;text-transform: uppercase;font-weight: 200;vertical-align: middle;box-shadow: none;display: block;float: left;" onMouseOver="this.style.backgroundColor=\'#afc149\'" onMouseOut="this.style.backgroundColor=\'#78d5e5\'">Buy Now</a>'; $product['created_at'] = date("Y-m-d H:i:s"); // Create Product $product_row = Product::create($product); $lastinsertedId = $product_row->id; // ++++++++++++++++++++++++++ Logic for insert brand name and tags in tag table +++++++++++++++++++++++++++++++++++++ $ii = 0; $allTags = array(); if ($product['tags'] != "") { $allTags = explode(",", $product['tags']); foreach ($allTags as $key => $value) { $all_data_arr[$ii]['value'] = $value; $all_data_arr[$ii]['type'] = 'tags'; $ii++; } } // get Brand Name from brand id $ii = $ii + 1; $brand_dtls = Brandmember::find(Request::input('brandmember_id')); $brand_name = $brand_dtls['fname'] . ' ' . $brand_dtls['lname']; $all_data_arr[$ii]['value'] = $brand_name; $all_data_arr[$ii]['type'] = 'brand_name'; //Insert Into searchtags table foreach ($all_data_arr as $key => $value) { $arr = array('product_id' => $lastinsertedId, 'type' => $value['type'], 'name' => trim($value['value'])); Searchtag::create($arr); } // ++++++++++++++++++++ Logic for insert brand name and tags in tag table +++++++++++++++++++++++++++++++++++++ // Create Product Ingredient group $flag = 0; if (NULL != Request::input('ingredient_group')) { foreach (Request::input('ingredient_group') as $key => $value) { // Check if that group contain atleast one ingredient if (isset($value['ingredient']) && NULL != $value['ingredient']) { foreach ($value['ingredient'] as $key1 => $next_value) { if ($next_value['ingredient_id'] != "" && $next_value['weight'] != "") { $flag = 1; break; } } } // ======================== Insert If flag==1 ===================== if ($flag == 1) { $arr = array('product_id' => $lastinsertedId, 'group_name' => $value['group_name']); $pro_ing_grp = ProductIngredientGroup::create($arr); $group_id = $pro_ing_grp->id; if (NULL != $value['ingredient']) { foreach ($value['ingredient'] as $key1 => $next_value) { if ($next_value['ingredient_id'] != "" && $next_value['weight'] != "") { $arr_next = array('product_id' => $lastinsertedId, 'ingredient_id' => $next_value['ingredient_id'], 'weight' => $next_value['weight'], 'ingredient_price' => $next_value['ingredient_price'], 'ingredient_group_id' => $group_id); ProductIngredient::create($arr_next); } } } } // ======================== Insert If flag==1 ===================== } } // Create Product Ingredient foreach (Request::input('ingredient') as $key2 => $ing_value) { if ($ing_value['id'] != "" && $ing_value['weight'] != "") { $arr_next = array('product_id' => $lastinsertedId, 'ingredient_id' => $ing_value['id'], 'weight' => $ing_value['weight'], 'ingredient_price' => $ing_value['ingredient_price'], 'ingredient_group_id' => 0); ProductIngredient::create($arr_next); } } // Add Ingredient form factor foreach (Request::input('formfactor') as $key3 => $formfactor_value) { $arr_pro_fac = array('product_id' => $lastinsertedId, 'formfactor_id' => $formfactor_value['formfactor_id'], 'servings' => $formfactor_value['servings'], 'min_price' => $formfactor_value['min_price'], 'recomended_price' => $formfactor_value['recomended_price'], 'actual_price' => $formfactor_value['actual_price']); ProductFormfactor::create($arr_pro_fac); } // Add Ingredient form factor for available form factor if (Request::input('excluded_val') != "") { $all_form_factor_ids = rtrim(Request::input('excluded_val'), ","); $all_ids = explode(",", $all_form_factor_ids); foreach ($all_ids as $key => $value) { $arr_pro_factor = array('product_id' => $lastinsertedId, 'formfactor_id' => $value); ProductFormfactor::create($arr_pro_factor); } } //Add count to MemberProfile $row = MemberProfile::where('brandmember_id', '=', Request::input('brandmember_id'))->first(); $row1 = array(); if (!empty($row)) { $count = $row->count + 1; MemberProfile::where('brandmember_id', '=', Request::input('brandmember_id'))->update(['count' => $count]); } else { $count = 1; $row1['count'] = $count; $row1['brandmember_id'] = Request::input('brandmember_id'); MemberProfile::create($row1); } Session::flash('success', 'Product added successfully'); return redirect('admin/product-list/0'); }
public function acceptOrder(Request $request) { $order = Order::findOrNew($request->get('order_id')); $order->status = 1; //accepted $order->save(); $product = Product::findOrNew($request->get('product_id')); $product->amount = $product->amount - $request->get('product_amount'); $product->save(); $bill = new Bill(); $bill->status = 0; $bill->customer_id = 1; $bill->order_id = $order->id; $bill->save(); $passingData = array('order_id' => $order->id, 'message_title' => 'Confirmed order', 'message_detail' => 'You order id ' . $request->get('order_id') . ' has been confirm (product_name : ' . $request->get('product_name') . ', order_date : ' . $request->get('order_date') . ')'); $data_string = json_encode($passingData); $url = curl_init('http://localhost:8080/api/order/confirm'); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_POSTFIELDS, $data_string); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); // response back $result = curl_exec($url); $data = array('name' => $order->customer->name, 'phone_number' => $order->customer->phone_number, 'email' => $order->customer->email, 'line1' => $order->customer->customerAddress->line1, 'district' => $order->customer->customerAddress->district, 'province' => $order->customer->customerAddress->province, 'post_code' => $order->customer->customerAddress->post_code, 'product_name' => $order->orderDetail->product->name, 'product_amount' => $order->orderDetail->amount, 'total_price' => $order->orderDetail->total_price, 'is_paid' => 0, 'order_id' => $order->id); $data_string = json_encode($data); $url2 = curl_init('http://localhost:8080/api/bill/create'); curl_setopt($url2, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url2, CURLOPT_POSTFIELDS, $data_string); curl_setopt($url2, CURLOPT_RETURNTRANSFER, true); curl_setopt($url2, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); $result2 = curl_exec($url2); $notificationData = array('message_title' => 'Notify Payment', 'message_detail' => 'Your bill which has order id ' . $request->get('order_id') . 'is waiting for payment.'); $data_string = json_encode($notificationData); $notificationUrl = curl_init('http://localhost:8080/api/notification/add'); curl_setopt($notificationUrl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($notificationUrl, CURLOPT_POSTFIELDS, $data_string); curl_setopt($notificationUrl, CURLOPT_RETURNTRANSFER, true); curl_setopt($notificationUrl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); // response back $result3 = curl_exec($notificationUrl); return redirect()->back(); }
<?php } ?> </ul> </div> </div> <div class="eight columns omega"> <h1 itemprop="name" class="product_name"><?php $_($product->name); ?> <small class="label label-<?php $_($product->in_stock ? $product->status : 'missing'); ?> "><?php $_($product->in_stock ? \App\Model\Product::getStatusLabel($product->status) : 'Отсутствует'); ?> </small> </h1> <p itemtype="http://data-vocabulary.org/Offer" itemscope="" itemprop="offerDetails" class="modal_price" style="display: inline; "> <meta content="RUR" itemprop="currency"> <meta content="Evolve Skateboards" itemprop="seller"> <meta content="in_stock" itemprop="availability"> <span class="sold_out"></span> <span class="" content="<?php echo $_format_price($product->Price, '%PRICE%'); ?> " itemprop="price">
public function update(Request $request, $id) { //echo "<pre>";print_r(Request::all());exit; if (Input::hasFile('image1')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image1')->getClientOriginalExtension(); // getting image extension $fileName1 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image1')->move($destinationPath, $fileName1); // uploading file to given path $this->obj->createThumbnail($fileName1, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName1, 109, 89, $destinationPath, $medium); } else { $fileName1 = Request::input('hidden_image1'); } if (Input::hasFile('image2')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image2')->getClientOriginalExtension(); // getting image extension $fileName2 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image2')->move($destinationPath, $fileName2); // uploading file to given path $this->obj->createThumbnail($fileName2, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName2, 109, 89, $destinationPath, $medium); } else { $fileName2 = Request::input('hidden_image2'); } if (Input::hasFile('image3')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image3')->getClientOriginalExtension(); // getting image extension $fileName3 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image3')->move($destinationPath, $fileName3); // uploading file to given path $this->obj->createThumbnail($fileName3, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName3, 109, 89, $destinationPath, $medium); } else { $fileName3 = Request::input('hidden_image3'); } if (Input::hasFile('image4')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image4')->getClientOriginalExtension(); // getting image extension $fileName4 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image4')->move($destinationPath, $fileName4); // uploading file to given path $this->obj->createThumbnail($fileName4, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName4, 109, 89, $destinationPath, $medium); } else { $fileName4 = Request::input('hidden_image4'); } if (Input::hasFile('image5')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image5')->getClientOriginalExtension(); // getting image extension $fileName5 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image5')->move($destinationPath, $fileName5); // uploading file to given path $this->obj->createThumbnail($fileName5, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName5, 109, 89, $destinationPath, $medium); } else { $fileName5 = Request::input('hidden_image5') != '' ? Request::input('hidden_image5') : ''; } if (Input::hasFile('image6')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image6')->getClientOriginalExtension(); // getting image extension $fileName6 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image6')->move($destinationPath, $fileName6); // uploading file to given path $this->obj->createThumbnail($fileName6, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName6, 109, 89, $destinationPath, $medium); } else { $fileName6 = Request::input('hidden_image6'); } $product = Product::find($id); $product['id'] = $id; $product['product_name'] = Request::input('product_name'); $product['product_slug'] = $this->obj->edit_slug($product['product_name'], 'products', 'product_slug', $id); $product['image1'] = $fileName1; $product['image2'] = $fileName2; $product['image3'] = $fileName3; $product['image4'] = $fileName4; $product['image5'] = $fileName5; $product['image6'] = $fileName6; $product['description1'] = htmlentities(Request::input('description1')); $product['description2'] = htmlentities(Request::input('description2')); $product['description3'] = htmlentities(Request::input('description3')); $product['tags'] = Request::input('tags'); $product['script_generated'] = '<a href="' . url() . '/product-details/' . $product['product_slug'] . '" style="color: #FFF;background: #78d5e5 none repeat scroll 0% 0%;padding: 10px 20px;font-weight: 400;font-size: 12px;line-height: 25px;text-shadow: none;border: 0px none;text-transform: uppercase;font-weight: 200;vertical-align: middle;box-shadow: none;display: block;float: left;" onMouseOver="this.style.backgroundColor=\'#afc149\'" onMouseOut="this.style.backgroundColor=\'#78d5e5\'">Buy Now</a>'; $product['created_at'] = date("Y-m-d H:i:s"); $product->save(); // Delete all ingredient before save new ProductIngredientGroup::where('product_id', '=', $id)->delete(); // Delete ingredient group ProductIngredient::where('product_id', '=', $id)->delete(); // Delete ingredient individual // Create Product Ingredient group if (NULL != Request::input('ingredient_group')) { foreach (Request::input('ingredient_group') as $key => $value) { $arr = array('product_id' => $id, 'group_name' => $value['group_name']); $pro_ing_grp = ProductIngredientGroup::create($arr); $group_id = $pro_ing_grp->id; if (NULL != $value['ingredient']) { foreach ($value['ingredient'] as $key1 => $next_value) { $arr_next = array('product_id' => $id, 'ingredient_id' => $next_value['ingredient_id'], 'weight' => $next_value['weight'], 'ingredient_price' => $next_value['ingredient_price'], 'ingredient_group_id' => $group_id); ProductIngredient::create($arr_next); } } } } // Create Product Ingredient foreach (Request::input('ingredient') as $key2 => $ing_value) { $arr_next = array('product_id' => $id, 'ingredient_id' => $ing_value['id'], 'weight' => $ing_value['weight'], 'ingredient_price' => $ing_value['ingredient_price'], 'ingredient_group_id' => 0); ProductIngredient::create($arr_next); } // Delete all Formfactor before save new ProductFormfactor::where('product_id', '=', $id)->delete(); // Add Ingredient form factor foreach (Request::input('formfactor') as $key3 => $formfactor_value) { $arr_pro_fac = array('product_id' => $id, 'formfactor_id' => $formfactor_value['formfactor_id'], 'servings' => $formfactor_value['servings'], 'min_price' => $formfactor_value['min_price'], 'recomended_price' => $formfactor_value['recomended_price'], 'actual_price' => $formfactor_value['actual_price']); ProductFormfactor::create($arr_pro_fac); } // Add Ingredient form factor for available form factor if (Request::input('excluded_val') != "") { $all_form_factor_ids = rtrim(Request::input('excluded_val'), ","); $all_ids = explode(",", $all_form_factor_ids); foreach ($all_ids as $key => $value) { $arr_pro_factor = array('product_id' => $id, 'formfactor_id' => $value); ProductFormfactor::create($arr_pro_factor); } } Session::flash('success', 'Product edit successfully'); return redirect('admin/product-list'); //echo "<pre>";print_r(Request::all());exit; }
public function update(Request $request, $id) { //echo "<pre>";print_r(Request::all());exit; if (Input::hasFile('image1')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image1')->getClientOriginalExtension(); // getting image extension $fileName1 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image1')->move($destinationPath, $fileName1); // uploading file to given path $this->obj->createThumbnail($fileName1, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName1, 109, 89, $destinationPath, $medium); } else { $fileName1 = Request::input('hidden_image1'); } if (Input::hasFile('image2')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image2')->getClientOriginalExtension(); // getting image extension $fileName2 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image2')->move($destinationPath, $fileName2); // uploading file to given path $this->obj->createThumbnail($fileName2, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName2, 109, 89, $destinationPath, $medium); } else { $fileName2 = Request::input('hidden_image2'); } if (Input::hasFile('image3')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image3')->getClientOriginalExtension(); // getting image extension $fileName3 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image3')->move($destinationPath, $fileName3); // uploading file to given path $this->obj->createThumbnail($fileName3, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName3, 109, 89, $destinationPath, $medium); } else { $fileName3 = Request::input('hidden_image3'); } if (Input::hasFile('image4')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image4')->getClientOriginalExtension(); // getting image extension $fileName4 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image4')->move($destinationPath, $fileName4); // uploading file to given path $this->obj->createThumbnail($fileName4, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName4, 109, 89, $destinationPath, $medium); } else { $fileName4 = Request::input('hidden_image4'); } if (Input::hasFile('image5')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image5')->getClientOriginalExtension(); // getting image extension $fileName5 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image5')->move($destinationPath, $fileName5); // uploading file to given path $this->obj->createThumbnail($fileName5, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName5, 109, 89, $destinationPath, $medium); } else { $fileName5 = Request::input('hidden_image5') != '' ? Request::input('hidden_image5') : ''; } if (Input::hasFile('image6')) { $destinationPath = 'uploads/product/'; // upload path $thumb_path = 'uploads/product/thumb/'; $medium = 'uploads/product/medium/'; $extension = Input::file('image6')->getClientOriginalExtension(); // getting image extension $fileName6 = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image6')->move($destinationPath, $fileName6); // uploading file to given path $this->obj->createThumbnail($fileName6, 771, 517, $destinationPath, $thumb_path); $this->obj->createThumbnail($fileName6, 109, 89, $destinationPath, $medium); } else { $fileName6 = Request::input('hidden_image6'); } $product = Product::find($id); $product['id'] = $id; $product['product_name'] = Request::input('product_name'); $product['product_slug'] = $this->obj->edit_slug($product['product_name'], 'products', 'product_slug', $id); $product['image1'] = $fileName1; $product['image2'] = $fileName2; $product['image3'] = $fileName3; $product['image4'] = $fileName4; $product['image5'] = $fileName5; $product['image6'] = $fileName6; $product['description1'] = htmlentities(Request::input('description1')); $product['description2'] = htmlentities(Request::input('description2')); $product['description3'] = htmlentities(Request::input('description3')); $product['tags'] = Request::input('tags'); $product['script_generated'] = '<a href="' . url() . '/product-details/' . $product['product_slug'] . '" style="color: #FFF;background: #78d5e5 none repeat scroll 0% 0%;padding: 10px 20px;font-weight: 400;font-size: 12px;line-height: 25px;text-shadow: none;border: 0px none;text-transform: uppercase;font-weight: 200;vertical-align: middle;box-shadow: none;display: block;float: left;" onMouseOver="this.style.backgroundColor=\'#afc149\'" onMouseOut="this.style.backgroundColor=\'#78d5e5\'">Buy Now</a>'; $product['created_at'] = date("Y-m-d H:i:s"); $product->save(); echo "<pre>"; print_r(Request::all()); exit; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // Product::destroy($id); redirect('/product'); }
public function productApi($slug) { $product = Product::whereSlug($slug)->first(); return response()->json(['product' => $product]); }
public function delete_product($id) { // Check if brand subscription expires show message $brand_details = Brandmember::find(Session::get('brand_userid')); if ($brand_details->subscription_status != "active") { Session::flash('error', 'Your subscription is over. Subscribe to delete products.'); return redirect('my-products'); } $product_update['id'] = $id; $product_update['discountinue'] = 1; $pro_result = Product::find($product_update['id']); $pro_result->update($product_update); Session::flash('success', 'Product deleted successfully'); return redirect('my-products'); }
public function getProducts() { return Product::get(); }
/** * API or removing materials being called from js */ public function removeSubProduct(Request $request) { $prodId = $request->input('product_id'); $subProdId = $request->input('sub_product_id'); //delete sub product MainSubProduct::where('product_id', $prodId)->where('sub_product_id', $subProdId)->delete(); //get all subproducts associated $curSubProducts = array(); $curSubProductIds = array(); $subProducts = Product::find($prodId)->sub_products()->get(); foreach ($subProducts as $pm) { //gets the current set materials $subprodExtObject = SubProduct::where('is_active', true)->where('id', $pm->sub_product_id)->first(); array_push($curSubProducts, $subprodExtObject); array_push($curSubProductIds, $pm->sub_product_id); $subprodExtObject = null; } //get all the subproducts not in current main product $allSubProducts = SubProduct::whereNotIn('id', $curSubProductIds)->orderBy('sub_product_name', 'asc')->get(); //return current and all materials return json_encode(array('curSubProducts' => $curSubProducts, 'allSubProducts' => $allSubProducts)); }
/** * @param Product $product * @param int $quantity */ public function removeProduct($product, $quantity = 1) { if ($quantity == 0) { return; } /** @var CartItems $item */ foreach ($_SESSION['cart_service']['items'] as $key => $item) { // If product already exists, just increase quantity if ($item->product_id == $product->id()) { if ($quantity >= 0 && $item->qty > $quantity) { $item->qty -= $quantity; } else { unset($_SESSION['cart_service']['items'][$key]); } return; } } }
/** * List all of the products. * * @return mixed */ public function lists() { return View::make('product.list')->withProducts(Product::all()); }
public function fetch($productId) { return Product::find($productId); }
public function delete_product($id) { $product_update['id'] = $id; $product_update['discountinue'] = 1; $pro_result = Product::find($product_update['id']); $pro_result->update($product_update); Session::flash('success', 'Product deleted successfully'); return redirect('my-products'); }
/** * Get order info by info posted. * * @param Request $request * @return array */ private function getOrderInfo(Request $request, $key) { $order = $request->get($key, []); $items = []; $total['price'] = 0; $total['number'] = 0; foreach ($order as $o) { $product = Product::find($o['index']); $item['index'] = $o['index']; $item['name'] = $product->name; $item['price'] = $product->price * $product->discount * $o['number']; $item['unit'] = $product->getUnit->name; $item['number'] = $o['number']; array_push($items, $item); $total['price'] += $item['price']; $total['number'] += $o['number']; } return array($items, $total); }