예제 #1
0
 /**
  * List the Preferred Areas for the user
  *
  * @access	public
  * @param	string	$userID
  * @return	json
  * @since	1.0.0
  */
 public function getPreferredArea()
 {
     $token = $_SERVER['HTTP_X_WOW_TOKEN'];
     $area = Request::all();
     return response()->json(Profile::getUserPreferences($token), 200);
 }
예제 #2
-1
 /**
  * Get the Profile details of the user
  *
  * @static	true
  * @access	public
  * @param	array $token
  * @since	1.0.0
  */
 public static function getUserProfile($token)
 {
     $queryProfileResult = DB::table('users as u')->leftjoin('user_attributes_date as uad', 'u.id', '=', 'uad.user_id')->leftjoin('user_attributes as ua', function ($join) {
         $join->on('uad.user_attribute_id', '=', 'ua.id')->where('ua.alias', '=', 'date_of_birth');
     })->leftjoin('locations as l', 'l.id', '=', 'u.location_id')->leftjoin('user_attributes_singleselect as uas', 'u.id', '=', 'uas.user_id')->leftjoin('user_attributes_select_options as uaso', 'uas.user_attributes_select_option_id', '=', 'uaso.id')->leftjoin('user_attributes as ua2', function ($join) {
         $join->on('uaso.user_attribute_id', '=', 'ua2.id')->where('ua2.alias', '=', 'gender');
     })->leftjoin('user_attributes_integer as uai', 'uai.user_id', '=', 'u.id')->leftjoin('user_attributes as ua3', 'ua3.id', '=', 'uai.user_attribute_id')->leftjoin('user_attributes as ua4', 'ua4.id', '=', 'uad.user_attribute_id')->leftjoin('user_devices as ud', 'u.id', '=', 'ud.user_id')->leftjoin('user_attributes_varchar as uav', 'uav.user_id', '=', 'u.id')->leftjoin('user_attributes as ua5', 'ua5.id', '=', 'uav.user_attribute_id')->where('ud.access_token', $token)->select('u.id as user_id', 'u.full_name', 'u.email', 'phone_number', 'u.zip_code', 'uaso.option as gender', 'l.id as location_id', 'l.name as location', 'ud.access_token', 'u.points_earned', 'u.points_spent', DB::raw('MAX(IF(ua5.alias = "membership_number", uav.attribute_value, 0)) AS membership_number'), DB::raw('MAX(IF(ua3.alias = "bookings_made", uai.attribute_value, 0)) AS bookings_made'), DB::raw('MAX(IF(ua4.alias = "date_of_birth", date(uad.attribute_value), 0)) AS dob'), DB::raw('MAX(IF(ua4.alias = "anniversary_date", date(uad.attribute_value), 0)) AS anniversary_date'))->groupby('u.id')->first();
     //Read all the preferred locations
     $preferredLocations = Profile::getUserPreferences($token);
     //Read all the AREAS related to user's location
     $cityAreas = Locations::readCityArea($queryProfileResult->location_id);
     //array to contain the response to be sent back to client
     $arrResponse = array();
     $lastReservationDetail = ReservationDetails::getUserLastReservation($queryProfileResult->user_id);
     //print_r($lastReservationDetail);
     if ($queryProfileResult) {
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         $arrResponse['data'] = array('user_id' => empty($queryProfileResult->user_id) ? "" : $queryProfileResult->user_id, 'full_name' => empty($queryProfileResult->full_name) ? "" : $queryProfileResult->full_name, 'email' => empty($queryProfileResult->email) ? "" : $queryProfileResult->email, 'phone_number' => $queryProfileResult->phone_number == 0 ? "" : (string) $queryProfileResult->phone_number, 'zip_code' => empty($queryProfileResult->zip_code) ? "" : $queryProfileResult->zip_code, 'gender' => empty($queryProfileResult->gender) ? "" : $queryProfileResult->gender, 'location_id' => empty($queryProfileResult->location_id) ? "" : $queryProfileResult->location_id, 'location' => empty($queryProfileResult->location) ? "" : $queryProfileResult->location, 'points_earned' => empty($queryProfileResult->points_earned) ? "" : $queryProfileResult->points_earned, 'points_spent' => empty($queryProfileResult->points_spent) ? "" : $queryProfileResult->points_spent, 'points_remaining' => $queryProfileResult->points_earned - $queryProfileResult->points_spent, 'bookings_made' => empty($queryProfileResult->bookings_made) ? "" : $queryProfileResult->bookings_made, 'membership_number' => empty($queryProfileResult->membership_number) ? "" : $queryProfileResult->membership_number, 'dob' => empty($queryProfileResult->dob) ? "" : $queryProfileResult->dob, 'anniversary_date' => empty($queryProfileResult->anniversary_date) ? "" : $queryProfileResult->anniversary_date, 'selectedPreferences' => empty($preferredLocations['data']) ? "" : $preferredLocations['data'], 'areas' => empty($cityAreas['data']) ? "" : $cityAreas['data'], 'last_reservation_date' => empty($lastReservationDetail->reservation_date) ? "" : $lastReservationDetail->reservation_date, 'last_reservation_time' => empty($lastReservationDetail->reservation_time) ? "" : date('H:i:s', strtotime($lastReservationDetail->reservation_time)));
     } else {
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         $arrResponse['data'] = array();
     }
     return $arrResponse;
 }