public function productPost(Request $request) { $obj = new helpers(); //echo "<pre>";print_r(Request::all());exit; if (Request::input('own_product') == 1) { 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, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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, 580, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName6, 109, 89, $destinationPath, $medium); } else { $fileName6 = Request::input('hidden_image6'); } $lastinsertedId = $id = Request::input('product_id'); $product = Product::find(Request::input('product_id')); $product['id'] = Request::input('product_id'); $product['own_product'] = Request::input('own_product'); $product['product_name'] = Request::input('product_name'); $product['product_slug'] = $obj->edit_slug($product['product_name'], 'products', 'product_slug', Request::input('product_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(); // ++++++++++++++++++++++++++ Logic for insert brand name and tags in tag table +++++++++++++++++++++++++++++++++++++ // Delete Search tags Searchtag::where('product_id', '=', $id)->delete(); $allTags = array(); $ii = 0; 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($product['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' => $id, 'type' => $value['type'], 'name' => trim($value['value'])); Searchtag::create($arr); } // ++++++++++++++++++++ Logic for insert brand name and tags in tag table +++++++++++++++++++++++++++++++++++++ // Delete all ingredient before save new ProductIngredientGroup::where('product_id', '=', $id)->delete(); // Delete ingredient group ProductIngredient::where('product_id', '=', $id)->delete(); // Delete ingredient individual $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 if (NULL != Request::input('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); } } } //echo "<pre>";print_r(Request::input('formfactor') );exit; // 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); } } else { // Update Old Product to discontinue product $product_update['id'] = Request::input('product_id'); $product_update['discountinue'] = 1; $pro_result = Product::find($product_update['id']); $pro_result->update($product_update); 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, 580, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName1, 109, 89, $destinationPath, $medium); // Delete old image // @unlink('uploads/product/'.Request::input('hidden_image1')); // @unlink('uploads/product/thumb/'.Request::input('hidden_image1')); // @unlink('uploads/product/medium/'.Request::input('hidden_image1')); } else { $fileName1 = Request::input('hidden_image1'); } 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($fileName1, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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($fileName1, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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($fileName1, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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($fileName1, 580, 270, $destinationPath, $home_thumb_path); $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/'; $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($fileName1, 580, 270, $destinationPath, $home_thumb_path); $obj->createThumbnail($fileName6, 109, 89, $destinationPath, $medium); } else { $fileName6 = Request::input('hidden_image6'); } $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['description1'] = htmlentities(Request::input('description1')); $product['description2'] = htmlentities(Request::input('description2')); $product['description3'] = htmlentities(Request::input('description3')); $product['brandmember_id'] = Session::get('brand_userid'); //$product['brandmember_id'] = 33; $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"); //echo "<pre>";print_r($product);exit; // Create Product $product_row = Product::create($product); $lastinsertedId = $product_row->id; // ++++++++++++++++++++++++++ Logic for insert brand name and tags in tag table +++++++++++++++++++++++++++++++++++++ if ($product['tags'] != "") { $allTags = explode(",", $product['tags']); $ii = 0; 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(Session::get('brand_userid')); $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', '=', Session::get('brand_userid'))->first(); $row1 = array(); if (!empty($row)) { $count = $row->count + 1; MemberProfile::where('brandmember_id', '=', Session::get('brand_userid'))->update(['count' => $count]); } else { $count = 1; $row1['count'] = $count; $row1['brandmember_id'] = Session::get('brand_userid'); MemberProfile::create($row1); } } Session::flash('success', 'Product updated successfully'); return redirect('my-products'); //exit; }
public function google() { $obj = new helpers(); $name = Request::input('name'); $checkout = Request::input('checkout'); $email = Request::input('email'); $membertype = Session::get('member_type'); $name = explode(" ", $name); if (count($name) > 0) { $fname = $name[0]; $lname = end($name); } else { $fname = $name; $lname = $name; } $username = strtolower($fname); $count = DB::table('brandmembers')->where('email', $email)->count(); if ($count > 0) { $member = DB::table('brandmembers')->where('email', $email)->first(); //brand member if ($member->role == 1 && empty($checkout) && $membertype == '1') { //redirect if admin deactivated account $user_cnt = DB::table('brandmembers')->where('email', $email)->where('status', 1)->where('admin_status', 1)->count(); if ($user_cnt <= 0) { $site = DB::table('sitesettings')->where('name', 'email')->first(); Session::put('error', 'Your Status is inactive. Contact Admin at ' . $site->value . ' to get your account activated!'); echo url() . '/brandLogin'; exit; } $this->check_subscription($member); Session::put('brand_userid', $member->id); Session::put('brand_user_email', $member->email); Session::put('member_username', $member->username); Session::put('social_login', 1); echo url() . "/brand-dashboard"; } elseif ($member->role == 1 && $membertype != '1') { Session::put('error', 'You are already registered as brand!'); echo url() . '/brandLogin'; } elseif ($member->role == 1 && !empty($checkout)) { Session::put('error', 'You are unable to login as brand!'); echo url(); } elseif ($member->role == 0 && $membertype == '1') { Session::put('error', 'You are already registered as member!'); echo url() . '/memberLogin'; exit; } elseif ($member->role == 0 && ($membertype == '0' || !empty($checkout))) { //redirect if admin deactivated account $user_cnt = DB::table('brandmembers')->where('email', $email)->where('status', 1)->where('admin_status', 1)->count(); if ($user_cnt <= 0) { $site = DB::table('sitesettings')->where('name', 'email')->first(); Session::put('error', 'Your Status is inactive. Contact Admin at ' . $site->value . ' to get your account activated!'); echo url() . '/memberLogin'; exit; } Session::put('member_userid', $member->id); Session::put('member_user_email', $member->email); Session::put('member_username', $member->username); Session::put('social_login', 1); $this->update_cart($member->id); if (!empty($checkout)) { echo url() . "/checkout"; } else { echo url() . "/member-dashboard"; } } } else { //create social users $checkout = Request::input('checkout'); if (!empty($checkout)) { Session::put('member_type', 0); } $membertype = Session::get('member_type'); if ($membertype == '1') { Session::put('error', 'Please register as brand for login!'); echo url() . '/brandregister'; exit; } $hashpassword = Hash::make(uniqid()); $slug = $obj->create_slug($fname . "-" . $lname, 'brandmembers', 'slug'); $brandmember = Brandmember::create(['email' => $email, 'fname' => $fname, 'lname' => $lname, 'username' => $username, 'password' => '', 'role' => Session::get('member_type'), 'admin_status' => 1, 'status' => 1, 'google_id' => Request::input('id'), 'slug' => $slug, 'business_name' => $fname . " " . $lname, 'updated_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s')]); $member = DB::table('brandmembers')->where('email', $email)->first(); $reg_brand_id = $member->id; $address = new Address(); $address->mem_brand_id = $reg_brand_id; $address->first_name = $fname; $address->last_name = $lname; $address->address = ''; $address->address2 = ''; $address->country_id = ''; $address->zone_id = ''; // State id $address->city = ''; $address->postcode = ''; $address->serialize_val = ''; if ($address->save()) { $addressId = $address->id; $dataUpdateAddress = DB::table('brandmembers')->where('id', $reg_brand_id)->update(['address' => $addressId]); } if ($member->role == 1) { $this->check_subscription($member); Session::put('brand_userid', $member->id); Session::put('brand_user_email', $member->email); Session::put('member_username', $member->username); Session::put('social_login', 1); echo url() . "/brand-dashboard"; } else { Session::put('member_userid', $member->id); Session::put('member_user_email', $member->email); Session::put('member_username', $member->username); Session::put('social_login', 1); $this->update_cart($member->id); if (!empty($checkout)) { echo url() . "/checkout"; } else { echo url() . "/member-dashboard"; } } } }
public function brandRegister() { $obj = new helpers(); if ($obj->checkUserLogin()) { return redirect('home'); } $country = DB::table('countries')->orderBy('name', 'ASC')->get(); $alldata = array(); foreach ($country as $key => $value) { $alldata[$value->country_id] = $value->name; } //echo "<pre>";print_r($alldata); exit; $reg_brand_id = ''; // No register brand id for first time. if (Request::isMethod('post')) { $country = DB::table('countries')->where('country_id', '=', Request::input('card_country_id'))->first(); $shipping_card_addr = array('card_holder_fname' => Request::input('card_holder_fname'), 'card_holder_lname' => Request::input('card_holder_lname'), 'company_name' => Request::input('company_name'), 'expiry_month' => Request::input('expiry_month'), 'expiry_year' => Request::input('expiry_year'), 'cvv' => Request::input('cvv'), 'card_shiping_name' => Request::input('card_shiping_name'), 'card_shiping_address' => Request::input('card_shiping_address'), 'card_country_id' => Request::input('card_country_id'), 'card_shiping_city' => Request::input('card_shiping_city'), 'card_shipping_phone_no' => Request::input('card_shipping_phone_no'), 'card_shipping_fax' => Request::input('card_shipping_fax'), 'card_state' => Request::input('card_state'), 'card_shipping_postcode' => Request::input('card_shipping_postcode'), 'email' => Request::input('email'), 'card_number' => Request::input('card_number'), 'country' => $country->name); $res = Authorizenet::createprofile($shipping_card_addr); // echo $res['status']; // echo $res['customer']['payment_profile_id']; //print_r($res);exit; if ($res['status'] == 'fail') { Session::flash('error', 'something went wrong with creditcard details!!' . $res[message] . ' Please try again.'); return redirect('brandregister'); } //echo $_FILES['image']['name']."<pre>";print_r($_FILES);exit; //if(Input::hasFile('government_issue')) if ($_FILES['government_issue']['name'] != "") { $destinationPath = 'uploads/brand_government_issue_id/'; // upload path $extension = Input::file('government_issue')->getClientOriginalExtension(); // getting image extension $government_issue = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('government_issue')->move($destinationPath, $government_issue); // uploading file to given path } else { $government_issue = ''; } //if(Input::hasFile('image')) if ($_FILES['image']['name'] != "") { $destinationPath = 'uploads/brandmember/'; // upload path $thumb_path = 'uploads/brandmember/thumb/'; $medium = 'uploads/brandmember/thumb/'; $extension = Input::file('image')->getClientOriginalExtension(); // getting image extension $fileName = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('image')->move($destinationPath, $fileName); // uploading file to given path $obj->createThumbnail($fileName, 661, 440, $destinationPath, $thumb_path); $obj->createThumbnail($fileName, 116, 116, $destinationPath, $medium); } else { $fileName = ''; } $slug = $obj->create_slug(Request::input('fname') . " " . Request::input('lname'), 'brandmembers', 'slug'); $hashpassword = Hash::make(Request::input('password')); $address = new Address(); $time = Request::input('calltime'); $date = Request::input('calldate'); $given_date = strtotime($date . " " . $time); $given_date = date("Y-m-d H:s:i", $given_date); $brandmember = Brandmember::create(['fname' => Request::input('fname'), 'lname' => Request::input('lname'), 'email' => Request::input('email'), 'username' => strtolower(Request::input('fname')), 'password' => $hashpassword, 'government_issue' => $government_issue, 'phone_no' => Request::input('phone_no'), 'routing_number' => Request::input('routing_number'), 'account_number' => Request::input('account_number'), 'mailing_name' => Request::input('mailing_name'), 'mailing_address' => Request::input('mailing_address'), 'mailing_country_id' => Request::input('mailing_country_id'), 'mailing_city' => Request::input('mailing_city'), 'mailing_lastname' => Request::input('mailing_lastname'), 'mailing_address2' => Request::input('mailing_address2'), 'mailing_state' => Request::input('mailing_state'), 'mailing_postcode' => Request::input('mailing_postcode'), 'call_datetime' => $given_date, 'paypal_email' => Request::input('paypal_email'), 'mailing_address' => Request::input('mailing_address'), 'default_band_preference' => Request::input('default_band_preference'), 'pro_image' => $fileName, 'role' => 1, 'admin_status' => 0, 'auth_profile_id' => $res['customer']['profile_id'], 'auth_payment_profile_id' => $res['customer']['payment_profile_id'], 'auth_address_id' => $res['customer']['address_id'], 'slug' => $slug]); $shipping_card_addr = array('card_holder_name' => Request::input('card_holder_name'), 'card_number' => Request::input('card_number'), 'card_name' => Request::input('card_name'), 'expiry_month' => Request::input('expiry_month'), 'expiry_year' => Request::input('expiry_year'), 'card_shiping_name' => Request::input('card_shiping_name'), 'card_shiping_address' => Request::input('card_shiping_address'), 'card_country_id' => Request::input('card_country_id'), 'card_shiping_city' => Request::input('card_shiping_city'), 'card_shipping_phone_no' => Request::input('card_shipping_phone_no'), 'card_shipping_address2' => Request::input('card_shipping_address2'), 'card_state' => Request::input('card_state'), 'card_shipping_postcode' => Request::input('card_shipping_postcode')); $shipping_card_addr_serial = serialize($shipping_card_addr); $lastInsertedId = $brandmember->id; $reg_brand_id = $lastInsertedId; //base64_encode ($lastInsertedId); // encrypted last register brand member id $address->mem_brand_id = $lastInsertedId; $address->first_name = Request::input('shiping_fname'); $address->last_name = Request::input('shiping_lname'); $address->address = Request::input('shiping_address'); $address->address2 = Request::input('shipping_address2'); $address->country_id = Request::input('country'); $address->zone_id = Request::input('state'); // State id $address->city = Request::input('city'); $address->postcode = Request::input('shipping_postcode'); $address->serialize_val = ''; if ($address->save()) { $addressId = $address->id; $dataUpdateAddress = DB::table('brandmembers')->where('id', $lastInsertedId)->update(['address' => $addressId]); $sitesettings = DB::table('sitesettings')->get(); //exit; if (!empty($sitesettings)) { foreach ($sitesettings as $each_sitesetting) { if ($each_sitesetting->name == 'email') { $admin_users_email = $each_sitesetting->value; } } } //Session::flash('success', 'Registration completed successfully.Please check your email to activate your account.'); //return redirect('brandregister'); $user_name = Request::input('fname') . ' ' . Request::input('lname'); $user_email = Request::input('email'); $activateLink = url() . '/activateLink/' . base64_encode(Request::input('email')) . '/brand'; $sent = Mail::send('frontend.register.activateLink', array('name' => $user_name, 'email' => $user_email, 'activate_link' => $activateLink), function ($message) use($admin_users_email, $user_email, $user_name) { $message->from($admin_users_email); $message->to($user_email, $user_name)->subject('Activate Profile Mail'); }); if (!$sent) { Session::flash('error', 'something went wrong!! Mail not sent.'); return redirect('brandregister'); } else { Session::flash('success', 'Registration completed successfully.Please check your email to activate your account.'); Session::flash('flush_reg_brand_id', 'open_modal'); Session::put('reg_brand_id', $reg_brand_id); return redirect('brandregister'); } } } return view('frontend.register.registerbrand', compact('alldata'), array('reg_brand_id' => $reg_brand_id)); }
public function productPost(Request $request) { $obj = new helpers(); //echo "<pre>";print_r(Request::all());exit; // Update Old Product to discontinue product $product_update['id'] = Request::input('product_id'); $product_update['discountinue'] = 1; $pro_result = Product::find($product_update['id']); $pro_result->update($product_update); 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 $obj->createThumbnail($fileName1, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName1, 109, 89, $destinationPath, $medium); // Delete old image // @unlink('uploads/product/'.Request::input('hidden_image1')); // @unlink('uploads/product/thumb/'.Request::input('hidden_image1')); // @unlink('uploads/product/medium/'.Request::input('hidden_image1')); } 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 $obj->createThumbnail($fileName2, 771, 517, $destinationPath, $thumb_path); $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 $obj->createThumbnail($fileName3, 771, 517, $destinationPath, $thumb_path); $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 $obj->createThumbnail($fileName4, 771, 517, $destinationPath, $thumb_path); $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 $obj->createThumbnail($fileName5, 771, 517, $destinationPath, $thumb_path); $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 $obj->createThumbnail($fileName6, 771, 517, $destinationPath, $thumb_path); $obj->createThumbnail($fileName6, 109, 89, $destinationPath, $medium); } else { $fileName6 = Request::input('hidden_image6'); } $product['product_name'] = Request::input('product_name'); $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['description1'] = htmlentities(Request::input('description1')); $product['description2'] = htmlentities(Request::input('description2')); $product['description3'] = htmlentities(Request::input('description3')); $product['brandmember_id'] = Session::get('brand_userid'); //$product['brandmember_id'] = 33; $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"); //echo "<pre>";print_r($product);exit; // Create Product $product_row = Product::create($product); $lastinsertedId = $product_row->id; // Create Product Ingredient group if (NULL != Request::input('ingredient_group')) { foreach (Request::input('ingredient_group') as $key => $value) { $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) { $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); } } } } // Create Product Ingredient foreach (Request::input('ingredient') as $key2 => $ing_value) { $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); } } Session::flash('success', 'Product updated successfully'); return redirect('my-products'); //exit; }