private function passData($id = null)
 {
     $products = new \App\Models\Products();
     if (!is_null($id)) {
         $products = Products::findOrNew($id);
     }
     if (!is_null($id)) {
         $cProducts = Products::where("id_Product", "!=", $id)->whereNull("Deleted")->orderBy('Product_Title')->get()->toArray();
         $attachments = $products->attachments()->get();
         $productFocusSubTypeList = $products->focusSubType()->get();
         $productCompetitors = $products->competitor()->get();
     } else {
         $cProducts = Products::whereNull("Deleted")->orderBy('Product_Title')->get()->toArray();
         if (!Session::has('ProductAttachments')) {
             Session::set('ProductAttachments', $products->attachments()->get());
         }
         $attachments = Session::get("ProductAttachments");
         if (!Session::has('ProductFocusSubType')) {
             Session::set('ProductFocusSubType', $products->focusSubType()->get());
         }
         $productFocusSubTypeList = Session::get("ProductFocusSubType");
         if (!Session::has('ProductCompetitors')) {
             Session::set('ProductCompetitors', $products->competitor()->get());
         }
         $productCompetitors = Session::get("ProductCompetitors");
     }
     //dd($productFocusSubTypeList);
     $pFocus = ProductFocus::all();
     $pfType = ProductFocusType::where("id_Product_Focus", "=", $products->id_Product_Focus ? $products->id_Product_Focus : 1)->get()->toArray();
     $pfsType = ProductFocusSubType::where("id_Product_Focus_Type", "=", $products->id_Product_Focus_Type ? $products->id_Product_Focus_Type : 1)->get()->toArray();
     $pPos = Positions::all()->toArray();
     $competitorProducts = [];
     foreach ($pFocus as $prFocus) {
         $productFocus[$prFocus["id_Product_Focus"]] = $prFocus["Product_Focus"];
     }
     foreach ($pfType as $prfFocus) {
         $productFocusType[$prfFocus["id_Product_Focus_Type"]] = $prfFocus["Product_Focus_Type"];
     }
     foreach ($pfsType as $prfsFocus) {
         $productFocusSubType[$prfsFocus["id_Product_Focus_Sub_Type"]] = $prfsFocus["Product_Focus_Sub_Type"];
     }
     foreach ($cProducts as $cpProducts) {
         $competitorProducts[$cpProducts["id_Product"]] = $cpProducts["Product_Title"];
     }
     foreach ($pPos as $prPos) {
         $positions[$prPos["id_Position"]] = $prPos["Position_Name"];
     }
     $Companies = Companies::SelectOptionsModel();
     $TargetEndUser = TargetEndUser::CheckboxesModel();
     $TargetMarket = TargetMarket::CheckboxesModel();
     $AssetClass = AssetClass::CheckboxesModel();
     $AvailabilityTerritory = AvailabilityTerritory::CheckboxesModel();
     $TargetEndUserSelection = $products->TargetEndUserSelection();
     $TargetMarketSelection = $products->TargetMarketSelection();
     $ClassAssetsSelection = $products->ClassAssetsSelection();
     $TerritorySelection = $products->TerritorySelection();
     return compact("products", "productFocus", "productFocusType", "productFocusSubType", "Companies", "TargetMarket", "TargetEndUser", "AssetClass", "competitorProducts", "AvailabilityTerritory", "positions", "attachments", "TerritorySelection", "TargetEndUserSelection", "TargetMarketSelection", "ClassAssetsSelection", "productFocusSubTypeList", "productCompetitors");
 }
示例#2
0
 public static function get_slite_products($user_id)
 {
     //Redirect to view products
     $Prod = Products::where('user_id', '=', $user_id)->get();
     $Prod = json_decode(json_encode($Prod), true);
     //print_r($Prod);
     //die();
     return $Prod;
 }
 public function Search()
 {
     if (!empty($_POST['search-control'])) {
         $search = $_POST['search-control'];
         $products = Products::where('products_name', 'LIKE', '%' . $search . '%')->get();
         $test = count($products);
         if ($test != 0) {
             foreach ($products as $product) {
                 echo $product->product_title;
                 echo $product->product_image;
                 echo $product->products_name;
                 echo $product->product_desc;
                 echo $product->Products_price;
                 echo $product->product_desc;
             }
         } else {
             // Make redirect to 404 page
             echo "404 page";
         }
     } else {
         echo "Empty field";
     }
 }
示例#4
0
 public function syncData()
 {
     $user_id = Auth::user()->id;
     $store_name = $this->get_store_name($user_id);
     $shopify = new Shopify(Token::$shopify_api_key, Token::$shopify_secret_key, $store_name);
     $rAllProducts = $shopify->get_all_products('GET');
     $rVariants = array();
     $sValues = "";
     $rInsert = array();
     foreach ($rAllProducts as $rP) {
         foreach ($rP as $rPP) {
             $rVariants[] = $rPP['variants'];
         }
     }
     foreach ($rVariants as $rV) {
         foreach ($rV as $rVV) {
             $rInsert[] = array('sku' => $rVV['sku'], 'product_name' => $rVV['title'], 'quantity' => $rVV['inventory_quantity'], 'price' => $rVV['price']);
         }
     }
     //print_r($rInsert);
     $rProd = Products::where('user_id', '=', $user_id)->get();
     $rProd = json_decode(json_encode($rProd), true);
     //Make SKU the key
     $rData = array();
     foreach ($rProd as $rP) {
         $key = $rP['sku'];
         $rData[$key]['product_name'] = $rP['product_name'];
         $rData[$key]['quantity'] = $rP['quantity'];
         $rData[$key]['price'] = $rP['price'];
     }
     $rDiff = array();
     $rNew = array();
     //print_r($rInsert);
     //die();
     //Compare both arrays now to see any difference and get the difference in new array
     foreach ($rInsert as $rI) {
         if (isset($rData[$rI['sku']])) {
             //Check for product_name, quantity,price
             if ($rI['product_name'] != $rData[$rI['sku']]['product_name']) {
                 $rDiff[$rI['sku']]['product_name'] = $rI['product_name'];
             }
             if ($rI['quantity'] != $rData[$rI['sku']]['quantity']) {
                 $rDiff[$rI['sku']]['quantity'] = $rI['quantity'];
             }
             if ($rI['price'] != $rData[$rI['sku']]['price']) {
                 $rDiff[$rI['sku']]['price'] = $rI['price'];
             }
         } else {
             $rNew[$rI['sku']]['product_name'] = $rI['product_name'];
             $rNew[$rI['sku']]['quantity'] = $rI['quantity'];
             $rNew[$rI['sku']]['price'] = $rI['price'];
         }
     }
     //Update each changed entry
     foreach ($rDiff as $rK => $rV) {
         $sQ = "update lookup_products set ";
         foreach ($rV as $rKK => $rVV) {
             $sQ .= "{$rKK} = '{$rVV}',";
         }
         $sQ = substr($sQ, 0, -1);
         $sQ .= " where sku = ?";
         DB::update($sQ, [$rK]);
     }
     //Add new Entry
     foreach ($rNew as $rK => $rV) {
         $sQ = "insert into lookup_products (sku,product_name,quantity,price,user_id) values (?, ?, ?, ?, ?)";
         DB::insert($sQ, [$rK, $rV['product_name'], $rV['quantity'], $rV['price'], $user_id]);
     }
     //Redirect to view products
     $Prod = Products::where('user_id', '=', $user_id)->get();
     return view('products.index', ['lookup_products' => $Prod]);
 }
示例#5
0
 public function productSummary($subGroup)
 {
     $results = '';
     $products = Products::where('product_group', $subGroup)->orderBy('group_order')->get();
     $results = '<tr>';
     $ctr = 0;
     $modd = 0;
     if (count($products) == 0) {
         $results .= "<td>No books in this category, Coming Soon</td>";
         $ctr = 8;
     }
     foreach ($products as $product) {
         $results .= "<td class='eighth'><a href=\"product/{$product->id}\"><img src=\"images\\{$product->image}\" width=\"135px;\"></a></td>";
         $results .= "<td ><a href=\"product/{$product->id}\">";
         $description = "<b>" . $product->product_name . "</b><br>" . $product->description . "<br><b>" . $product->Author . "</b><br>" . $product->display_description;
         $results .= substr($description, 0, 260) . "...</a></td>";
         $ctr++;
         $ctr++;
         $modd = $ctr % 6;
         \Log::info("ctr={$ctr}  mod={$modd}");
         if ($modd == 0) {
             $results .= "</tr><tr>";
         }
     }
     $results = $this->addBlanks($results, $modd);
     $results .= "</tr>";
     return $results;
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $product = Products::where('id', '=', $id)->get();
     return view('product.edit', ['product' => $product]);
 }
示例#7
0
 public function anyProductDescription($product_uid)
 {
     $product = Products::where('uid', $product_uid)->first();
     $error_msg = [];
     $reviews = NULL;
     $main_image = NULL;
     if (!$product) {
         $error_msg[] = 'Sorry, product not found.';
     } else {
         $reviews = ProductReviews::where('product_id', $product->id)->where('approved', 1)->get();
         $product_main_image = ProductImages::where('product_id', $product->id)->where('is_primary', 1)->first();
         $main_image = $product_main_image->url;
     }
     return View::make('shop.product_view', ['product' => $product, 'error_msg' => $error_msg, 'reviews' => $reviews, 'main_image' => '../../../storage/app/upload/' . $main_image]);
 }
示例#8
0
 public function multiKindSummarySub($productCategory)
 {
     $results = '';
     if ($productCategory > 0) {
         $products = Products::where('store_id', '>', 0)->where('product_category', $productCategory)->orderBy('product_name')->get();
     } else {
         $products = Products::where('store_id', '>', 0)->orderBy('product_name')->get();
     }
     $results = '<tr>';
     $ctr = 0;
     $modd = 0;
     if (count($products) == 0) {
         $results .= "<td>No Products in Product Category, Coming Soon</td>";
         $ctr = 8;
     }
     foreach ($products as $product) {
         $results .= "<td class='eighth'><a href=\"/multikind/{$product->id}\"><img src=\"/images\\{$product->image}\" width=\"135px;\"></a></td>";
         $results .= "<td class='fifth' ><a href=\"/multikind/{$product->id}\">";
         $description = "<b>" . $product->product_name . "</b><br>" . $product->description . "<br><b>" . $product->display_description;
         $results .= substr($description, 0, 260) . "...</a></td>";
         $ctr++;
         $ctr++;
         $modd = $ctr % 6;
         \Log::info("ctr={$ctr}  mod={$modd}");
         if ($modd == 0) {
             $results .= "</tr><tr>";
         }
     }
     $results = $this->addBlanks($results, $modd);
     $results .= "</tr>";
     return $results;
 }
示例#9
0
 public function seller()
 {
     $user_id = Products::where('id', $this->product_id)->first()->user_id;
     return User::where('id', $user_id)->first()->name;
 }