public function checkoutMemberLogin() { $obj = new helpers(); if ($obj->checkMemberLogin()) { return redirect('member-dashboard'); } if ($obj->checkBrandLogin()) { return redirect('brand-dashboard'); } if (Request::isMethod('post')) { $email = Request::input('email'); $password = Request::input('password'); $encrypt_pass = Hash::make($password); $login_arr = array('email' => $email, 'password' => $encrypt_pass); $users = DB::table('brandmembers')->where('email', $email)->where('role', 0)->first(); // Only member Can Login here // print_r($_POST);exit; if ($users != "") { $user_pass = $users->password; // check for password if (Hash::check($password, $user_pass)) { // Check for active $user_cnt = DB::table('brandmembers')->where('email', $email)->where('status', 1)->where('admin_status', 1)->count(); //echo $user_cnt;exit; //echo DB::enableQueryLog();exit; if ($user_cnt) { Session::put('member_userid', $users->id); Session::put('member_user_email', $users->email); Session::put('member_username', ucfirst($users->username)); Session::forget('step1'); Session::forget('guest_array'); Session::forget('guest'); Session::forget('step3'); //Set the user cart $this->update_cart($users->id); return redirect('/checkout'); } else { $site = DB::table('sitesettings')->where('name', 'email')->first(); Session::flash('error', 'Your Status is inactive. Contact Admin at ' . $site->value . ' to get your account activated!'); return redirect('/checkout'); } } else { Session::flash('error', 'Email and password does not match.'); return redirect('/checkout'); } } else { Session::flash('error', 'This email-id is not register as a member.'); return redirect('/checkout'); } } return view('frontend.checkout.checkout_setp1', compact('body_class'), array('title' => 'MIRAMIX | checkout')); }
public function delAddress() { $obj = new helpers(); if (!$obj->checkMemberLogin()) { return redirect('memberLogin'); } $id = Request::input('id'); if (empty($id)) { return redirect('member-shipping-address'); } $address = Address::find($id); try { if ($address->delete()) { Session::flash('success', 'Shipping Address successfully deleted.'); return redirect('member-shipping-address'); } else { Session::flash('error', 'Unable to delete record.'); return redirect('member-shipping-address'); } } catch (PDOException $e) { } }
public function checkoutStep4() { $obj = new helpers(); if ($obj->checkMemberLogin() && !$obj->checkBrandLogin()) { $sitesettings = DB::table('sitesettings')->get(); if (!empty($sitesettings)) { foreach ($sitesettings as $each_sitesetting) { if ($each_sitesetting->name == 'shipping_rate') { $shipping_rate = (int) $each_sitesetting->value; } } } if (Request::isMethod('post')) { $shp_address = DB::table('addresses')->where('mem_brand_id', Session::get('member_userid'))->where('id', Session::get('selected_address_id'))->first(); // Serialize the Shipping Address because If user delete there address from "addresses" table,After that the address also store in the "order" table for getting order history// $shiping_address = array('address_title' => $shp_address->address_title, 'mem_brand_id' => $shp_address->mem_brand_id, 'first_name' => $shp_address->first_name, 'last_name' => $shp_address->last_name, 'email' => $shp_address->email, 'phone' => $shp_address->phone, 'address' => $shp_address->address, 'address2' => $shp_address->address2, 'city' => $shp_address->city, 'zone_id' => $shp_address->zone_id, 'country_id' => $shp_address->country_id, 'postcode' => $shp_address->postcode); $shiping_address_serial = serialize($shiping_address); $order = Order::create(['order_total' => Request::input('grand_total'), 'sub_total' => Request::input('sub_total'), 'order_status' => 'pending', 'shipping_address_id' => Session::get('selected_address_id'), 'shipping_cost' => $shipping_rate, 'shipping_type' => 'flat', 'user_id' => Session::get('member_userid'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_method' => Session::get('payment_method'), 'transaction_id' => '', 'transaction_status' => '', 'shiping_address_serialize' => $shiping_address_serial, 'created_at' => date('Y-m-d H:s:i'), 'updated_at' => date('Y-m-d H:s:i')]); $last_order_id = $order->id; $allCart = DB::table('carts')->where('user_id', Session::get('member_userid'))->get(); foreach ($allCart as $eachCart) { $product_details = DB::table('products')->where('id', $eachCart->product_id)->first(); // echo $each_content->brandmember_id; exit; $brandmember_deatils = DB::table('products')->leftJoin('brandmembers', 'brandmembers.id', '=', 'products.brandmember_id')->select('products.*', 'brandmembers.fname', 'brandmembers.lname', 'brandmembers.username', 'brandmembers.slug', 'brandmembers.pro_image', 'brandmembers.brand_details', 'brandmembers.brand_sitelink', 'brandmembers.status', 'brandmembers.admin_status')->where('products.id', '=', $eachCart->product_id)->first(); //echo "<pre>";print_r($brandmember_deatils); exit; //echo $brandmember->slug ; exit; $brand_member_name = $brandmember_deatils->fname ? $brandmember_deatils->fname . ' ' . $brandmember_deatils->lname : $brandmember_deatils->username; $formfactor = DB::table('form_factors')->where('id', '=', $eachCart->form_factor)->first(); $order_item = OrderItems::create(['order_id' => $last_order_id, 'brand_id' => $brandmember_deatils->brandmember_id, 'brand_name' => $brand_member_name, 'product_id' => $eachCart->product_id, 'product_name' => $eachCart->product_name, 'product_image' => $product_details->image1, 'quantity' => $eachCart->quantity, 'price' => $eachCart->amount, 'form_factor_id' => $formfactor->id, 'form_factor_name' => $formfactor->name]); // All Cart deleted from cart table after inserting all data to order and order_item table. //$deleteCart = Cart::where('user_id', '=', Session::get('member_userid'))->delete(); } if (Session::get('payment_method') == 'creditcard') { return redirect('/checkout-authorize/' . $last_order_id); } elseif (Session::get('payment_method') == 'paypal') { return redirect('/checkout-paypal/' . $last_order_id); } } // All Cart Contain In Session Will Display Here // $content = DB::table('carts')->where('user_id', Session::get('member_userid'))->get(); //echo "<pre>";print_r($content); exit; foreach ($content as $each_content) { $product_res = DB::table('products')->where('id', $each_content->product_id)->first(); // echo $each_content->brandmember_id; exit; $brandmember = DB::table('products')->leftJoin('brandmembers', 'brandmembers.id', '=', 'products.brandmember_id')->select('products.*', 'brandmembers.fname', 'brandmembers.lname', 'brandmembers.username', 'brandmembers.slug', 'brandmembers.pro_image', 'brandmembers.brand_details', 'brandmembers.brand_sitelink', 'brandmembers.status', 'brandmembers.admin_status')->where('products.id', '=', $each_content->product_id)->first(); //echo "<pre>";print_r($brandmember); //echo $brandmember->slug ; exit; $brand_name = $brandmember->fname ? $brandmember->fname . ' ' . $brandmember->lname : $brandmember->username; $formfactor = DB::table('form_factors')->where('id', '=', $each_content->form_factor)->first(); $formfactor_name = $formfactor->name; $formfactor_id = $formfactor->id; $cart_result[] = array('rowid' => $each_content->row_id, 'product_name' => $each_content->product_name, 'product_slug' => $brandmember->product_slug, 'product_image' => $product_res->image1, 'qty' => $each_content->quantity, 'price' => $each_content->amount, 'duration' => $each_content->duration, 'formfactor_name' => $formfactor_name, 'formfactor_id' => $formfactor_id, 'brand_name' => $brand_name, 'brand_slug' => $brandmember->slug, 'subtotal' => $each_content->sub_total); } //echo "sph= ".$shipping_rate; exit; return view('frontend.checkout.checkout_setp4', compact('body_class', 'cart_result', 'shipping_rate'), array('title' => 'MIRAMIX | Checkout-Step4')); } else { redirect('/checkout-step1'); } }
public function deleteCart() { $obj = new helpers(); $rowid = Input::get('rowid'); Cart::remove($rowid); // Delete cart product from SESSION respect with cart rowid. if ($obj->checkMemberLogin()) { DB::table('carts')->where('row_id', '=', $rowid)->where('user_id', '=', Session::get('member_userid'))->delete(); // Delete cart product from DB respect with cart rowid. } //destroy cart $cartcount = Cart::count(); if ($cartcount <= 0) { Cart::destroy(); } echo 1; // Remove from cart }
public function brand_login() { //echo Hash::make(123456); exit; $obj = new helpers(); if ($obj->checkMemberLogin()) { return redirect('member-dashboard'); } if ($obj->checkBrandLogin()) { return redirect('brand-dashboard'); } if (Request::isMethod('post')) { $email = Request::input('email'); $password = Request::input('password'); $users = DB::table('brandmembers')->where('email', $email)->where('role', 1)->first(); if ($users != "") { $user_pass = $users->password; // check for password if (Hash::check($password, $user_pass)) { // Check for active $user_cnt = DB::table('brandmembers')->where('email', $email)->where('status', 1)->count(); if ($user_cnt) { // Check for remember me if (Request::input('remember_me') == 1) { Cookie::queue(Cookie::make('brand_email', Request::input('email'), 60 * 24 * 30)); } Session::put('brand_userid', $users->id); Session::put('brand_user_email', $users->email); return redirect('brand-dashboard'); } else { Session::flash('error', 'Your Status is inactive. Contact Admin to activated your account'); return redirect('brandLogin'); } } else { Session::flash('error', 'Email and password does not match.'); return redirect('brandLogin'); } } else { Session::flash('error', 'Email and password does not match.'); return redirect('brandLogin'); } } // check for remenber me cookie $brand_email = ''; $brand_email = Cookie::get('brand_email'); return view('frontend.home.brand_login', compact('brand_email'), array('title' => 'MIRAMIX | Brand Login')); }
public function brand_login() { if (substr($_SERVER['SERVER_NAME'], 0, 4) != "www." && $_SERVER['SERVER_NAME'] != '192.168.1.112' && $_SERVER['SERVER_NAME'] != 'localhost') { header('Location: http://www.' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); } /*if( ! Request::secure() ) { return Redirect::secure( Request::path() ); }*/ $obj = new helpers(); if ($obj->checkMemberLogin()) { return redirect('member-dashboard'); } if ($obj->checkBrandLogin()) { return redirect('brand-dashboard'); } Session::put('member_type', 1); if (Request::isMethod('post')) { $email = Request::input('email'); $password = Request::input('password'); $users = DB::table('brandmembers')->where('email', $email)->where('role', 1)->first(); if ($users != "") { $user_pass = $users->password; // check for password if (Hash::check($password, $user_pass)) { // Check for active $user_cnt = DB::table('brandmembers')->where('email', $email)->where('status', 1)->count(); if ($user_cnt) { $this->check_subscription($users); // Check for remember me if (Request::input('remember_me') == 1) { Cookie::queue(Cookie::make('brand_email', Request::input('email'), 60 * 24 * 30)); } Session::put('brand_userid', $users->id); Session::put('brand_user_email', $users->email); Session::put('brand_username', ucfirst($users->username)); return redirect('brand-dashboard'); } else { Session::flash('error', 'Your Status is inactive. Contact Admin to activated your account'); return redirect('brandLogin'); } } else { Session::flash('error', 'Email and password does not match.'); return redirect('brandLogin'); } } else { Session::flash('error', 'Email and password does not match.'); return redirect('brandLogin'); } } // check for remenber me cookie $brand_email = ''; $brand_email = Cookie::get('brand_email'); $subfee = DB::table('sitesettings')->where('name', 'brand_fee')->first(); $subprofee = DB::table('sitesettings')->where('name', 'brand_perproduct_fee')->first(); return view('frontend.home.brand_login', compact('brand_email', 'subfee', 'subprofee'), array('title' => 'MIRAMIX | Brand Login')); }