public function store(Request $request)
 {
     $register = Request::all();
     //print_r($register);
     $obj = new helpers();
     if (Input::hasFile('image')) {
         $destinationPath = 'uploads/img/';
         // upload path
         $thumb_path = 'uploads/img/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, 300, 200, $destinationPath, $thumb_path);
     } else {
         $fileName = '';
     }
     $hashpassword = Hash::make($register['password']);
     $address = new Address();
     $brandmember = Brandmember::create(['fname' => $register['fname'], 'lname' => $register['lname'], 'email' => $register['email'], 'password' => $hashpassword, 'phone_no' => $register['phone_no'], 'pro_image' => $fileName, 'role' => 0, 'admin_status' => 1, 'updated_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s')]);
     $lastInsertedId = $brandmember->id;
     $address->mem_brand_id = $lastInsertedId;
     $address->address = $register['address'];
     $address->address2 = $register['address2'];
     $address->country_id = $register['country'];
     $address->zone_id = $register['state'];
     // State id
     $address->city = $register['city'];
     $address->postcode = $register['postcode'];
     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;
                 }
             }
         }
         $user_name = $register['fname'] . ' ' . $register['lname'];
         $user_email = $register['email'];
         $activateLink = url() . '/activateLink/' . base64_encode($register['email']);
         $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('register');
         } else {
             Session::flash('success', 'Registration completed successfully.Please check your email to activate your account.');
             return redirect('register');
         }
     }
 }
Example #2
0
 public function see($idRestaurant)
 {
     //Get the restaurant by its id
     $restaurant = Restaurant::getOneBy(array('_id' => new \MongoId($idRestaurant)));
     //If User is not logged in
     if (!Session::isConnected() || Session::getUser()->getType() != USER_CLIENT) {
         Session::addFlashMessage("Non connecté", "error", "Veuillez vous connecter avant de continuer.");
         return Redirect::to('/restaurant');
     }
     //If it doesn't exist, return to the list
     if (!$restaurant) {
         return Redirect::to('/restaurant');
     }
     $client = Session::getUser();
     $addresses = Address::getBy(array('user' => $client->getId()));
     if (Form::exists('order_form')) {
         $commande = new Commande();
         $menus = $restaurant->getMenus();
         $total = 0;
         foreach ($menus as $menu) {
             $menuItems = $menu->getMenuItems();
             foreach ($menuItems as $menuItem) {
                 $quantity = Form::get($menuItem->getId()->__toString());
                 if ($quantity > 0) {
                     $commande->setItem($menuItem, $quantity);
                 }
                 $total += $menuItem->getPrice() * $quantity;
             }
         }
         //If we didn't choose any item
         if ($total == 0) {
             return Redirect::to('/restaurant/see/' . $idRestaurant);
         }
         $commande->setPrice($total);
         $commande->setClient($client);
         $addressId = Form::get('address');
         $address = null;
         if ($addressId == 'altAddress') {
             //Then we take in accout the altAdress field
             $address = new Address();
             $address->setAddress(Form::get('altAdress'));
             $address->setUser($client);
         } else {
             $address = Address::getOneBy(array('_id' => new \MongoId($addressId)));
             if (!$address) {
                 die("Erreur à gérer.");
             }
         }
         $address->setByDefault();
         $address->save();
         $commande->setAddress($address);
         $commande->setStatus(Commande::COMMAND_STATUS_TEMPORARY);
         $commande->save();
         return Redirect::to("/restaurant/validateCommand/" . $commande->getId());
     }
     return View::render("restaurant/see.php", array('restaurant' => $restaurant, 'client' => Session::getUser(), 'addresses' => $addresses));
 }
Example #3
0
 /**
  * Takes all the Adresses linked to the
  */
 function setByDefault()
 {
     $addresses = Address::getBy(array('user' => $this->user));
     //Need to get User
     foreach ($addresses as $address) {
         $address->removeByDefault();
         $address->save();
     }
     $this->defaultAddress = TRUE;
 }
Example #4
0
 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) {
     }
 }
Example #5
0
 public function checkoutStep4()
 {
     $obj = new helpers();
     $shp_address = array();
     $sitesettings = DB::table('sitesettings')->get();
     if (!empty($sitesettings)) {
         foreach ($sitesettings as $each_sitesetting) {
             if ($each_sitesetting->name == 'shipping_rate') {
                 $shipping_rate = (double) $each_sitesetting->value;
             }
             if ($each_sitesetting->name == 'free_discount_rate') {
                 $free_discount_rate = (double) $each_sitesetting->value;
             }
         }
     }
     if (Request::isMethod('post')) {
         Session::put('name_card', Input::get('name_card'));
         //Input::get('name_card');
         Session::put('card_number', Input::get('card_number'));
         //Input::get('card_number'); //"4042760173301988";//
         Session::put('card_exp_month', Input::get('card_exp_month'));
         // "03"; //
         Session::put('card_exp_year', Input::get('card_exp_year'));
         // "19"; //
         //checkout as guest
         if (!Session::has('member_userid')) {
             $guestdata = Session::get('guest_array');
             $shiping_address = array('address_title' => 'default address', 'first_name' => $guestdata["guest_fname"], 'last_name' => $guestdata["guest_lname"], 'email' => $guestdata["guest_email"], 'phone' => $guestdata["guest_phone"], 'address' => $guestdata["guest_address"], 'address2' => $guestdata["guest_address2"], 'city' => $guestdata["guest_city"], 'zone_id' => $guestdata["guest_state"], 'country_id' => $guestdata["guest_country_id"], 'postcode' => $guestdata["guest_zip_code"]);
             $want_reg = Request::input('register_user');
             if ($want_reg == 'register') {
                 //register the member
                 Session::put('guest_username_sess', Request::input('guest_username'));
                 $brandmember = Brandmember::create(['fname' => $guestdata['guest_fname'], 'lname' => $guestdata['guest_lname'], 'email' => $guestdata['guest_email'], 'username' => Request::input('guest_username'), 'password' => Hash::make(Request::input('guest_password')), 'role' => 0, 'admin_status' => 1, 'status' => 1, 'updated_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s')]);
                 $lastInsertedId = $brandmember->id;
                 $shiping_address['mem_brand_id'] = $brandmember->id;
                 $shp_address = Address::create($shiping_address);
                 $lastAddressId = DB::getPdo()->lastInsertId();
                 $user_id = $brandmember->id;
                 // Update Address id in brandmember table
                 $addressId = $shp_address->id;
                 $dataUpdateAddress = DB::table('brandmembers')->where('id', $brandmember->id)->update(['address' => $addressId]);
             } else {
                 //set userid for not loggedin users to pass the order
                 $user_id = NULL;
                 $shp_address['id'] = NULL;
                 $shp_address = (object) $shp_address;
                 //print_r($shp_address); exit;
             }
             // End of registration ==================================================
             /* To get the country code And Zone code */
             $shp_country = DB::table('countries')->where('country_id', $guestdata["guest_country_id"])->first();
             $shp_zone = DB::table('zones')->where('zone_id', $guestdata["guest_state"])->first();
             $shiping_address = array('address_title' => 'default address', 'first_name' => $guestdata["guest_fname"], 'last_name' => $guestdata["guest_lname"], 'email' => $guestdata["guest_email"], 'phone' => $guestdata["guest_phone"], 'address' => $guestdata["guest_address"], 'address2' => $guestdata["guest_address2"], 'city' => $guestdata["guest_city"], 'zone_id' => $shp_zone->code, 'country_id' => $shp_country->iso_code_3, 'postcode' => $guestdata["guest_zip_code"]);
             //print_r($shiping_address); exit;
             $shiping_address_serial = serialize($shiping_address);
         } else {
             //for logged-in users
             $shp_address = DB::table('addresses')->leftjoin('countries', 'countries.country_id', '=', 'addresses.country_id')->leftjoin('zones', 'zones.zone_id', '=', 'addresses.zone_id')->select('addresses.*', 'countries.name as country_name', 'countries.iso_code_3 as country_code', 'zones.name as zone_name', 'zones.code as zone_code')->where('mem_brand_id', Session::get('member_userid'))->where('id', Session::get('selected_address_id'))->first();
             //echo "<pre>111111";print_r($shp_address); exit;
             // 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_code, 'country_id' => $shp_address->country_code, 'postcode' => $shp_address->postcode);
             $shiping_address_serial = serialize($shiping_address);
             //echo "pm= ".Session::get('payment_method'); exit;
             $user_id = Session::get('member_userid');
         }
         $order = Order::create(['order_total' => Request::input('grand_total'), 'sub_total' => Request::input('sub_total'), 'discount' => Request::input('discount'), 'redeem_amount' => Request::input('redeem_amount'), 'order_status' => 'pending', 'shipping_address_id' => $shp_address->id, 'shipping_cost' => Request::input('shipping_rate'), 'shipping_type' => 'flat', 'user_id' => $user_id, '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;
         $obj = new helpers();
         $order_number = 'ORD-' . $obj->random_string(5) . '-' . $last_order_id;
         // Generate random String for order number
         $update_order_number = DB::table('orders')->where('id', $last_order_id)->update(['order_number' => $order_number]);
         Session::put('order_number', $order_number);
         Session::put('order_id', $last_order_id);
         ///we are not storing new registered cart in cart table as it will be destroyed soon
         if (Session::has('member_userid')) {
             $allCart = DB::table('carts')->where('user_id', Session::get('member_userid'))->get();
         } else {
             $allCart = $obj->content();
             foreach ($allCart as $each_content) {
                 $each_content->product_id = $each_content->id;
                 $each_content->form_factor = $each_content->options->form_factor;
                 $each_content->row_id = $each_content->rowid;
                 $each_content->product_name = $each_content->name;
                 $each_content->quantity = $each_content->qty;
                 $each_content->amount = $each_content->price;
                 $each_content->duration = $each_content->options->duration;
                 $each_content->sub_total = $each_content->subtotal;
                 $each_content->no_of_days = $each_content->options->no_of_days;
             }
         }
         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.email', '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, 'brand_email' => $brandmember_deatils->email, '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, 'duration' => $eachCart->duration, 'no_of_days' => $eachCart->no_of_days]);
             //All Cart deleted from cart table after inserting all data to order and order_item table.
             if (Session::has('member_userid')) {
                 $deleteCart = DB::table('carts')->where('user_id', '=', Session::get('member_userid'))->delete();
             }
             Cart::destroy();
             // After inserting all cart data into Order and Order_item Table database
         }
         //set points for users on purchase
         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);
         }
     }
     //end of post
     /*
     		
     
     // 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'));
     */
 }
Example #6
0
 private function addCommande()
 {
     $commandes = Commande::getBy(array());
     $mail = true;
     while (count($commandes) <= 5) {
         $commande = new Commande();
         $restaurant = Restaurant::getOneBy(array('name' => 'Ma Queue Mickey'));
         $item = ItemMenu::getOneBy(array('name' => 'Burger'));
         $address = Address::getOneBy(array('address' => '18 Rue des Roses'));
         $commande->setItem($item, 2);
         $commande->setStatus(Commande::COMMAND_STATUS_PAYED);
         $commande->setDatetime('12/12/12 12:12');
         $commande->createConfirmationCode();
         $commande->setAddress($address);
         $client = Client::getOneBy(array('_mail' => "*****@*****.**"));
         $commande->setClient($client);
         $commande->save();
         $restaurant->save();
         $commandes = Commande::getBy(array());
     }
 }
Example #7
0
 public function setAddress(Address $address)
 {
     if (!isset($address)) {
         trigger_error('The adress must have a value', E_USER_WARNING);
     } else {
         $this->_mainAdress = $address->getId();
     }
 }
Example #8
0
 public function delAddress()
 {
     $obj = new helpers();
     if (!$obj->checkBrandLogin()) {
         return redirect('brandLogin');
     }
     $id = Request::input('id');
     if (empty($id)) {
         return redirect('brand-shipping-address');
     }
     $address = Address::find($id);
     $address->delete();
     Session::flash('success', 'Shipping Address successfully deleted.');
     return redirect('brand-shipping-address');
 }
Example #9
0
 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));
 }
Example #10
0
 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";
             }
         }
     }
 }
Example #11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $obj = new helpers();
     $brandUpdate = Request::all();
     $brand = Brandmember::find($id);
     if ($brandUpdate['password'] == '') {
         unset($brandUpdate['password']);
     } else {
         $brandUpdate['password'] = Hash::make(Request::input('password'));
     }
     /*  
            if($brandUpdate['slug']==''){
     	unset($brandUpdate['slug']);
            }else{
     	$brandUpdate['slug']=$obj->edit_slug(Request::input('slug'),'brandmembers','slug',$id);
     	
            }*/
     $brandUpdate['slug'] = $obj->edit_slug(Request::input('slug'), 'brandmembers', 'slug', $id);
     $address['first_name'] = Request::input('first_name');
     $address['last_name'] = Request::input('last_name');
     $address['address'] = Request::input('address1');
     $address['address2'] = Request::input('address2');
     $address['country_id'] = Request::input('country_id');
     $address['zone_id'] = Request::input('zone_id');
     // State id
     $address['city'] = Request::input('city');
     $address['postcode'] = Request::input('postcode');
     Address::where('id', '=', Request::input('address'))->update($address);
     unset($brandUpdate['first_name']);
     unset($brandUpdate['last_name']);
     unset($brandUpdate['address1']);
     unset($brandUpdate['address2']);
     unset($brandUpdate['country_id']);
     unset($brandUpdate['zone_id']);
     unset($brandUpdate['city']);
     unset($brandUpdate['postcode']);
     if (isset($_FILES['pro_image']['name']) && $_FILES['pro_image']['name'] != "") {
         $destinationPath = 'uploads/brandmember/';
         // upload path
         $thumb_path = 'uploads/brandmember/thumb/';
         $medium = 'uploads/brandmember/thumb/';
         $extension = Input::file('pro_image')->getClientOriginalExtension();
         // getting image extension
         $fileName = rand(111111111, 999999999) . '.' . $extension;
         // renameing image
         Input::file('pro_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 = '';
     }
     if ($fileName == '') {
         unset($brandUpdate['pro_image']);
     } else {
         $brandUpdate['pro_image'] = $fileName;
     }
     if (isset($_FILES['government_issue']['name']) && $_FILES['government_issue']['name'] != "") {
         $destinationPath = 'uploads/brand_government_issue_id/';
         // upload path
         $extension = Input::file('government_issue')->getClientOriginalExtension();
         $government_issue = rand(111111111, 999999999) . '.' . $extension;
         Input::file('government_issue')->move($destinationPath, $government_issue);
         // uploading file to given path
     } else {
         $government_issue = '';
     }
     if ($government_issue == '') {
         unset($brandUpdate['government_issue']);
     } else {
         $brandUpdate['government_issue'] = $government_issue;
     }
     if (isset($_FILES['business_doc']['name']) && $_FILES['business_doc']['name'] != "") {
         $destinationPath = 'uploads/brandmember/business_doc/';
         // upload path
         $extension = Input::file('business_doc')->getClientOriginalExtension();
         $business_doc = rand(111111111, 999999999) . '.' . $extension;
         Input::file('business_doc')->move($destinationPath, $business_doc);
     } else {
         $business_doc = '';
     }
     if ($business_doc == '') {
         unset($brandUpdate['business_doc']);
     } else {
         $brandUpdate['business_doc'] = $business_doc;
     }
     $brand->update($brandUpdate);
     Session::flash('success', 'Brand updated successfully');
     return redirect('admin/brand');
 }
Example #12
0
 /**
  * Return the address of the command
  * @return \App\Model\Address
  */
 function getAddress()
 {
     return Address::getOneBy(array('_id' => $this->_address));
 }
 public function addAddress()
 {
     if (Input::has('addressID')) {
         $rules = ['description_modal' => 'required', 'address_modal' => 'required', 'city_modal' => 'required', 'country_modal' => 'required', 'zip_modal' => 'required', 'phone_modal' => 'required', 'email_modal' => 'required|email'];
     } else {
         $rules = ['description' => 'required', 'address' => 'required', 'city' => 'required', 'country' => 'required', 'zip' => 'required', 'phone' => 'required', 'email' => 'required|email'];
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(['result' => 'failed', 'error' => $validator->getMessageBag()->toArray()]);
     } else {
         if (Input::has('addressID')) {
             $addressID = Input::get('addressID');
             $address = AddressModel::find($addressID);
             $peopleId = Input::get('peopleID');
             $address->peopleId = Input::get('peopleID');
             $address->addressDesc = Input::get('description_modal');
             $address->address = Input::get('address_modal');
             $address->addressLine2 = Input::get('address2_modal');
             $address->city = Input::get('city_modal');
             $address->state = Input::get('state_modal');
             $address->zip = Input::get('zip_modal');
             $address->province = Input::get('province_modal');
             $address->country = Input::get('country_modal');
             $address->phone = Input::get('phone_modal');
             $address->email = Input::get('email_modal');
             $address->save();
         } else {
             $address = new AddressModel();
             $peopleId = Input::get('peopleID');
             $address->peopleId = Input::get('peopleID');
             $address->addressDesc = Input::get('description');
             $address->address = Input::get('address');
             $address->addressLine2 = Input::get('address2');
             $address->city = Input::get('city');
             $address->state = Input::get('state');
             $address->zip = Input::get('zip');
             $address->province = Input::get('province');
             $address->country = Input::get('country');
             $address->phone = Input::get('phone');
             $address->email = Input::get('email');
             $address->save();
         }
         $addressList = AddressModel::whereRaw('peopleId=?', array($peopleId))->get();
         $countList = count($addressList);
         $list = "";
         for ($i = 0; $i < count($addressList); $i++) {
             if ($i % 2 == 0) {
                 $list .= "<div class='row'>";
             }
             $list .= '<div class="col-md-6">
                             <div class="panel panel-blue margin-bottom-40">
                                 <div class="panel-heading">
                                     <h3 class="panel-title">';
             $list .= $addressList[$i]->addressDesc;
             $list .= '<a herf="javascript:void(0)" onclick="onEdit(' . $addressList[$i]->id . ')" style="cursor: pointer"> [ Edit ] </a>
                                     </h3>
                                 </div>
                                 <div class="panel-body">
                                     <div class="margin-bottom-40" >
                                         <div class="form-group">
                                             <p>' . $addressList[$i]->address . " " . $addressList[$i]->addressLine2 . '</p>
                                         </div>
                                         <div class="form-group">
                                             <p>' . $addressList[$i]->city . ', ';
             if ($addressList[$i]->state != "") {
                 $list .= $addressList[$i]->state;
                 if ($addressList[$i]->province != "") {
                     $list .= "(" . $addressList[$i]->province . "), " . $addressList[$i]->zip;
                 } else {
                     $list .= ", " . $addressList[$i]->zip;
                 }
             } else {
                 if ($addressList[$i]->province != "") {
                     $list .= "(" . $addressList[$i]->province . "), " . $addressList[$i]->zip;
                 } else {
                     $list .= " " . $addressList[$i]->zip;
                 }
             }
             $list .= '</p>
                                          </div>
                                         <div class="form-group">
                                             <p>' . $addressList[$i]->country . '</p>
                                         </div>
                                         <div class="form-group">
                                             <p>' . $addressList[$i]->phone . ' - ' . $addressList[$i]->email . '</p>
                                         </div>
                                     </div>
                                 </div>
                             </div>
                         </div>';
             $countList = $countList - 1;
             if ($i % 2 == 1 || $countList == 0) {
                 $list .= '</div>';
             }
         }
         $countList = count($addressList);
         return Response::json(['result' => 'success', 'list' => $list, 'countAddress' => $countList, 'message' => "Address saved successfully."]);
     }
 }