public function login() { try { $passwordMatch = false; $userDeviceUpdated = false; $access_token = ''; $input = Request::all(); $user = User::where('email', $input['email'])->first(); if ($user) { if (crypt($input['password'], $user->password) == $user->password) { $passwordMatch = true; } } if ($passwordMatch) { $userDevice = UserDevice::where('device_id', $input['device_id'])->first(); $access_token = Uuid::uuid1()->toString(); if ($userDevice) { $userDeviceUpdated = $userDevice->update(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]); } else { $userDeviceUpdated = UserDevice::create(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]); } } if ($userDeviceUpdated) { $vendorLocationContact = VendorLocationContact::where('user_id', $user->id)->first(); $vendorLocation = VendorLocation::where('id', $vendorLocationContact->vendor_location_id)->first(); $vendor = Vendor::where('id', $vendorLocation->vendor_id)->first(); return response()->json(['id' => $user->id, 'access_token' => $access_token, 'full_name' => $user->full_name, 'email' => $user->email, 'phone_number' => $user->phone_number, 'role' => $user->role->name, 'vendor_name' => $vendor->name], 200); } else { return response()->json(['action' => 'Check if the email address and password match', 'message' => 'There is an email password mismatch. Please check and try again'], 227); } } catch (\Exception $e) { return response()->json(['message' => 'An application error occured.', 'error' => $e->getMessage()], 500); } }
/** * Updates the user password to the new value. * * @static * @access public * @param array $arrData * @return array * @since 1.0.0 */ public static function updatePasswordDatabase($arrData) { $user = PasswordRequest::where('request_token', '=', $arrData['token'])->first(); $password = bcrypt($arrData['password']); User::where('id', '=', $user['user_id'])->update(['password' => $password, 'type' => 'new_site']); PasswordRequest::where('request_token', '=', $arrData['token'])->update(['status' => 'used']); $arrResponse['status'] = Config::get('constants.API_SUCCESS'); $arrResponse['msg'] = 'Password set successfully.'; return $arrResponse; }
public function getByUserId($id) { $userWithAttributes = User::with('role', 'attributesBoolean', 'attributesDate', 'attributesInteger', 'attributesFloat', 'attributesText', 'attributesVarChar', 'attributesSingleSelect', 'attributesMultiSelect')->find($id); $this->populateUserAttributes($userWithAttributes->attributesBoolean); $this->populateUserAttributes($userWithAttributes->attributesInteger); $this->populateUserAttributes($userWithAttributes->attributesFloat); $this->populateUserAttributes($userWithAttributes->attributesDate); $this->populateUserAttributes($userWithAttributes->attributesText); $this->populateUserAttributes($userWithAttributes->attributesVarChar); $this->populateUserAttributes($userWithAttributes->attributesSingleSelect); $this->populateUserAttributes($userWithAttributes->attributesMultiSelect); return ['user' => User::find($id), 'attributes' => $this->attributes]; }
public function changeReservationStatus($reservation_id, $data) { $userModel = User::find($data['user_id']); //$reservStatus = new ReservationStatus(); $statusId = $data['status']; $reservType = isset($data['reserv_type']) ? $data['reserv_type'] : ""; //$reservStatus->save(); $statusLog = ReservStatusLog::where('reservation_id', '=', $reservation_id)->orderBy('id', 'desc')->take(1)->get(); if ($statusLog->isEmpty()) { $statusLogEntry = new ReservStatusLog(); $statusLogEntry->reservation_id = $reservation_id; $statusLogEntry->user_id = $userModel->id; $statusLogEntry->old_reservation_status_id = 0; $statusLogEntry->new_reservation_status_id = $statusId; $statusLogEntry->save(); } else { $statusLogEntry = new ReservStatusLog(); $statusLogEntry->reservation_id = $reservation_id; $statusLogEntry->user_id = $userModel->id; $statusLogEntry->old_reservation_status_id = $statusLog[0]->new_reservation_status_id; $statusLogEntry->new_reservation_status_id = $statusId; $statusLogEntry->save(); } if (!empty($data['addons'])) { //print_r($data['addons']);die; if (isset($data['mobile']) && $data['mobile'] == 1) { /*foreach($data['addons'] as $key => $detail) { $result = ReservAddonVarientDetails::where('options_id', $detail['prod_id'])->where('reservation_id', $reservation_id)->first(); $result->reservation_status_id = $statusId; $result->save(); }*/ foreach ($data['addons'] as $addonInfo) { //print_r($addonInfo['prod_id']);die; if ($addonInfo['qty'] > 0) { $result = new ReservAddonVarientDetails(); $result->no_of_persons = $addonInfo['qty']; $result->options_id = $addonInfo['prod_id']; $result->option_type = 'addon'; $result->reservation_type = 'experience'; $result->reservation_id = $reservation_id; $result->reservation_status_id = $statusId; $result->save(); } } //self::addActualAddonTakers($reservation_id,$data['addons']); } else { /*foreach ($data['addons'] as $prod_id => $count) { if($count > 0) { $result = ReservAddonVarientDetails::where('options_id', $prod_id)->where('reservation_id', $reservation_id)->first(); $result->reservation_status_id = $statusId; $result->save(); } //print_r($result);die; }*/ self::addActualAddonTakers($reservation_id, $data['addons']); } } /*if($statusId == 1 || $statusId == 2 || $statusId == 3){ $this->pushToRestaurant($reservation_id); }*/ if (!empty($reservType)) { switch ($statusId) { case 2: //for edited status //prepare the array for sending status to zoho $zoho_data = array('Order_completed' => 'User Changed'); if ($reservType == "Experience") { $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data); } else { if ($reservType == "Alacarte") { $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data); } } break; case 3: //for cancelled status $zoho_data = array('Order_completed' => 'User Cancelled'); if ($reservType == "Experience") { $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data); } else { if ($reservType == "Alacarte") { $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data); } } break; case 6: //for accepted status $adminComments = DB::table('reservation_attributes_text')->where('reservation_id', $reservation_id)->where('reservation_attribute_id', 17)->select('attribute_value')->first(); $zoho_data = array('Order_completed' => 'Confirmed with rest & customer', 'Satisfaction' => $adminComments->attribute_value); if ($reservType == "Experience") { $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data); } else { if ($reservType == "Alacarte") { $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data); } } break; case 7: //for rejected status $zoho_data = array('Order_completed' => 'Rejected by restaurant'); if ($reservType == "Experience") { $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data); } else { if ($reservType == "Alacarte") { $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data); } } break; case 8: //for closed status $zoho_data = array('Order_completed' => 'yes'); if ($reservType == "Experience") { $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data); } else { if ($reservType == "Alacarte") { $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data); } } break; } } return "Success"; }
public function register() { $rules = ['email' => 'required|email', 'password' => 'required', 'city' => 'required']; $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { $string_msg = ""; $messages = head($validator->messages()); // echo "<pre>"; // print_r(Input::all());exit; foreach (head($messages) as $key => $value) { $string_msg .= $value . "\n"; } echo $string_msg; } $res = User::where('email', Input::get('email'))->get()->toArray(); if (count($res) >= 1) { echo "This email address is already registered with WowTables.com "; } else { $google_add = Cookie::get('google_add_words'); $users['email_address'] = Input::get('email'); $users['password'] = Input::get('password'); $users['city'] = Input::get('city'); $users['full_name'] = Input::get('full_name'); $login_type = Input::get('login_type'); $reg_page = Input::get('reg_page'); $usr_phone = Input::get('phone'); $gourmetRoleId = DB::table('roles')->where('name', 'Gourmet')->pluck('id'); $users['role_id'] = $gourmetRoleId; $users['google_addwords'] = isset($google_add) && $google_add == 1 ? "1" : "0"; $users['last_login'] = '******'; $users['facebook_id'] = 0; if ($users['facebook_id'] != 0) { $facebook_id = $users['facebook_id']; } $registerinfo = $this->customermodel->register($users); $last_id = $registerinfo['user_id']; // update membership_number // update email_whitelist if ($registerinfo['state'] === 'success') { if (isset($login_type) && $login_type != "") { $set_login_type = $login_type; } else { $set_login_type = "Email"; } if (isset($reg_page) && $reg_page != "") { $set_reg_page = $reg_page; } else { $set_reg_page = "http://www.wowtables.com/registration"; } $usr_email = Input::get('email'); if ($usr_phone != "") { DB::update("update users set phone_number ='{$usr_phone}' where email = '{$usr_email}'"); } $newdata = array('id' => $last_id, 'username' => substr($users['email_address'], 0, strpos($users['email_address'], "@")), 'email' => $users['email_address'], 'logged_in' => TRUE, 'city' => $users['city']); $newdata['add_mixpanel_event'] = 'yes'; $newdata['login_type'] = $set_login_type; $newdata['Registration_Page'] = $set_reg_page; Session::put($newdata); $mailbody = "\nYou are now a WowTables VIP!\n\nThank you for joining WowTables.com!\n\nYour account details are:\nEmail:" . $users['email_address'] . "\nPassword:"******"\n\nWe add new experiences from the best restaurants in Mumbai,Pune,Delhi,Bengaluru every week. So the next time you feel like treating yourself or a loved one to something special just check out WowTables.com or call our concierge at 9619551387 to make a booking. We hope you will enjoy what we have to offer.\n\nHappy Dining,\nThe WowTables Team"; $city_name = Location::where(['Type' => 'City', 'id' => $users['city']])->pluck('name'); if (empty($city_name)) { $city_name = 'mumbai'; } /*Mail::raw($mailbody, function($message) use ($users) { $message->from('*****@*****.**', 'WowTables by GourmetItUp'); $message->to($users['email_address'])->subject('Registration with WowTables'); });*/ /*$newdata = array( 'id' => $last_id, 'username' => substr($users['email_address'],0,strpos($users['email_address'],"@")), 'email' => $users['email_address'], 'logged_in' => TRUE, 'city' => $users['city'] ); $newdata['add_mixpanel_event'] = 'yes'; $newdata['login_type'] = $set_login_type; $newdata['Registration_Page'] = $set_reg_page;*/ //$this->email->send(); //Start MailChimp //require_once 'MCAPI.class.php'; //specify the proper path /*if(!isset($_GET["utm_source"])) $_GET["utm_source"] = ""; if(!isset($_GET["utm_medium"])) $_GET["utm_medium"] = ""; if(!isset($_GET["utm_campaign"])) $_GET["utm_campaign"] = "";*/ $city = ucfirst($city_name); $merge_vars = array('NAME' => isset($users['full_name']) ? $users['full_name'] : '', 'SIGNUPTP' => isset($facebook_id) ? 'Facebook' : 'Email', 'BDATE' => isset($users['dob']) ? $users['dob'] : '', 'GENDER' => isset($users['gender']) ? $users['gender'] : '', 'MERGE11' => 0, 'MERGE17' => 'Has WowTables account', 'PHONE' => isset($users['phone']) ? $users['phone'] : '', 'MERGE18' => isset($_GET["utm_source"]) ? $_GET["utm_source"] : '', 'MERGE19' => isset($_GET["utm_medium"]) ? $_GET["utm_medium"] : '', 'MERGE20' => isset($_GET["utm_campaign"]) ? $_GET["utm_campaign"] : '', 'GROUPINGS' => array(array('id' => 9713, 'groups' => [$city]))); $this->mailchimp->lists->subscribe($this->listId, ["email" => $_POST['email']], $merge_vars, "html", false, true); //print_r($test);die; //echo "<pre>"; print_r($api); die; //$api->listSubscribe($listId, $_POST['email'], $merge_vars,"html",false,true ); //$my_email = $users['email_address']; //$city = $users['city']; //echo "asd , "; //$this->mailchimp->lists->interestGroupings($this->listId,true); //print_r($test);die; //$test = $this->mailchimp->lists->updateMember($this->listId, ["email"=>$_POST['email']], $mergeVars); //print_r($test);die; //End MailChimp echo 1; } else { echo $registerinfo['message']; } } }
public function create_reward($id) { $users = \WowTables\Http\Models\Eloquent\User::find($id); $rewards = $this->user->get_all_records($id); $points_earned = $this->user->get_all_points_earned($id); $points_spent = $this->user->get_all_points_spent($id); return view('admin.users.rewards', ['user_id' => $id, 'rewards' => $rewards, 'users' => $users, 'points_earned' => $points_earned, 'points_spent' => $points_spent]); }
public function today() { $todayBookings = array(); $count = 0; $statusCancelledNew = DB::select(DB::raw('select rd.id as reservation_id,rd.user_id as user_id from reservation_details as rd left join reservation_attributes_date as rad on rd.id = rad.reservation_id where DATE(rad.attribute_value) = \'' . Carbon::now()->format('Y-m-d') . '\'')); $reservationIdArr = array(); foreach ($statusCancelledNew as $reservId) { $reservationIdArr[$reservId->reservation_id] = $reservId->user_id; } $reservStatusArr = $this->reservationDetails->getReservationStatus(array_keys($reservationIdArr), [1, 2, 3, 6, 7, 8]); $todayPaginate = ReservationDetails::with('experience', 'vendor_location.vendor', 'vendor_location.address.city_name', 'attributesDatetime')->where('vendor_location_id', '!=', '0')->where('vendor_location_id', '!=', '54')->whereIn('id', array_keys($reservationIdArr))->where('created_at', '>=', '2015-10-12 15:20:00')->orderBy('created_at', 'desc')->paginate(15); foreach (ReservationDetails::with('experience', 'vendor_location.vendor', 'vendor_location.address.city_name', 'attributesDatetime')->where('vendor_location_id', '!=', '0')->where('vendor_location_id', '!=', '54')->whereIn('id', array_keys($reservationIdArr))->where('created_at', '>=', '2015-10-12 15:20:00')->orderBy('created_at', 'desc')->paginate(15) as $today) { $booking = new \stdClass(); $booking->id = $today->id; /*$reservCarbonDate = Carbon::createFromFormat('Y-m-d H:i:s',$today->attributesDatetime->attribute_value); $booking->bdate = $reservCarbonDate->format('d-m-Y'); $booking->btime = $reservCarbonDate->format('h:i A');*/ if ($today->product_id == 0) { $booking->name = "Classic Reservation"; } else { $booking->name = $today->experience->name; } $booking->cust_name = $today->guest_name; if (isset($today->vendor_location->vendor->name)) { $booking->restaurant_name = $today->vendor_location->vendor->name; } else { $booking->restaurant_name = ""; } if (empty($today->vendor_location->address->city_name)) { $booking->city = ""; } else { $booking->city = $today->vendor_location->address->city_name->name; } //$reservStatus = $today->reservationStatus->first(); //dd($reservStatus); $booking->email = $today->guest_email; $booking->phone_no = $today->guest_phone; $booking->no_of_persons = $today->no_of_persons; //$booking->status = $reservStatus->status; $userModel = User::find($reservationIdArr[$today->id]); $booking->lastmodified = $userModel->role->name; $booking->user_id = $today->user_id; $statusArr = $this->reservStatuses; $statusKey = array_search($reservStatusArr[$today->id], $statusArr); if ($statusKey != -1) { unset($statusArr[$statusKey]); } $booking->reserv_status = $reservStatusArr[$today->id][0]; $booking->statusArr = $statusArr; $reservationDetailsAttr = $this->reservationDetails->getByReservationId($today->id); $booking->special_request = isset($reservationDetailsAttr['attributes']['special_request']) ? $reservationDetailsAttr['attributes']['special_request'] : ""; $booking->gift_card_id = isset($reservationDetailsAttr['attributes']['gift_card_id_reserv']) ? $reservationDetailsAttr['attributes']['gift_card_id_reserv'] : ""; $booking->outlet = isset($reservationDetailsAttr['attributes']['outlet']) ? $reservationDetailsAttr['attributes']['outlet'] : ""; $booking->reserv_type = $reservationDetailsAttr['attributes']['reserv_type']; $reservCarbonDate = Carbon::createFromFormat('Y-m-d H:i:s', $reservationDetailsAttr['attributes']['reserv_datetime']); $booking->bdate = $reservCarbonDate->format('d-m-Y'); $booking->btime = $reservCarbonDate->format('h:i A'); $todayBookings[$count] = $booking; $count++; //print_r($today); } return view('admin.bookings.list.today')->with('todaysbookings', $todayBookings)->with('today_paginate', $todayPaginate); }