public function index() { $all_brand_member = DB::table('brandmembers')->where('role', 1)->where('status', 1)->where('admin_status', 1)->get(); DB::connection()->enableQueryLog(); foreach ($all_brand_member as $brand) { $product = DB::table('products')->select(DB::raw('products.id,products.brandmember_id,products.product_name,products.product_slug,products.image1, MIN(`actual_price`) as `min_price`,MAX(`actual_price`) as `max_price`'))->leftJoin('product_formfactors', 'products.id', '=', 'product_formfactors.product_id')->where('products.brandmember_id', '=', $brand->id)->where('products.active', 1)->where('products.is_deleted', 0)->where('product_formfactors.servings', '!=', 0)->where('products.discountinue', 0)->groupBy('product_formfactors.product_id'); $profile = MemberProfile::find($brand->id); if (isset($profile) && $profile->count) { $count = (int) $profile->count; } else { $count = 0; } $setting = DB::table('sitesettings')->where('name', 'brand_fee')->first(); $setting2 = DB::table('sitesettings')->where('name', 'brand_perproduct_fee')->first(); if ($count == 1) { $fee = $setting->value; } elseif ($count > 1) { $fee = $setting->value; $perproduct_fee = $setting2->value; $fee = $fee + $perproduct_fee * $count; } else { $fee = 0; } //echo $brand->id; //echo '<br />'; $br = array('member_fee' => $fee); //print_r($br); DB::table('brandmembers')->where('id', $brand->id)->update(array('member_fee' => $fee)); } foreach ($all_brand_member as $brand) { //echo $brand->fname; $subscription = DB::table('subscription_history')->where('payment_status', 'pending')->where('member_id', $brand->id)->first(); if (count($subscription) <= 0) { $paidsub = DB::table('subscription_history')->where('payment_status', 'paid')->where('member_id', $brand->id)->orderBy('end_date', 'DESC')->first(); if (count($paidsub) > 0) { $start_date = $paidsub->end_date; $end_date = date("Y-m-d", strtotime($start_date . ' + 30 days')); } else { $start_date = $brand->created_at; $end_date = date("Y-m-d", strtotime($start_date . ' + 30 days')); } $setting = DB::table('sitesettings')->where('name', 'brand_fee')->first(); $subdata = array("member_id" => $brand->id, "start_date" => $start_date, "end_date" => $end_date, "subscription_fee" => $brand->member_fee); Subscription::create($subdata); } else { $paidsubscription = DB::table('subscription_history')->where('member_id', $brand->id)->orderBy('end_date', 'DESC')->first(); if (is_object($paidsubscription) && $paidsubscription->end_date <= date("Y-m-d") && $paidsubscription->payment_status == 'paid') { echo 'subid-' . $paidsubscription->subscription_id . '- paid in prev month <br />'; } else { $today = Date('Y-m-d'); $enddate = date("Y-m-d", strtotime($subscription->end_date . " + 1 day")); if ($enddate <= $today) { //charge here if (empty($brand->auth_profile_id)) { continue; } echo "will be charged " . $subscription->member_id . '<br />'; // Create Auth & Capture Transaction $request = new AuthorizeNetCIM(); $transaction = new AuthorizeNetTransaction(); $transaction->amount = $brand->member_fee; $transaction->customerProfileId = $brand->auth_profile_id; $transaction->customerPaymentProfileId = $brand->auth_payment_profile_id; $transaction->customerShippingAddressId = $brand->auth_address_id; $lineItem = new AuthorizeNetLineItem(); $lineItem->itemId = $subscription->subscription_id; $lineItem->name = $brand->fname; $lineItem->description = $brand->fname . " charged for subscription of " . $subscription->start_date; $lineItem->quantity = "1"; $lineItem->unitPrice = $brand->member_fee; $lineItem->taxable = "false"; $transaction->lineItems[] = $lineItem; $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction); $updateWithCode = DB::table('brandmembers')->where('id', '=', $subscription->member_id)->update(array('subscription_status' => 'expired')); if ($response->isOk()) { $transactionResponse = $response->getTransactionResponse(); $transactionId = $transactionResponse->transaction_id; $subdata = array("transaction_id" => $transactionResponse->transaction_id, "payment_status" => 'paid'); $sub = DB::table('subscription_history')->where('subscription_id', $subscription->subscription_id)->update($subdata); $updateWithCode = DB::table('brandmembers')->where('id', '=', $subscription->member_id)->update(array('subscription_status' => 'active')); } else { print_r($response); } } } } } $this->onlineusers(); }
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; }