public function postPersonalizedBusinesses()
 {
     $processing = array();
     $not_processing = array();
     $post = json_decode(file_get_contents("php://input"));
     if ($post) {
         $user_timezone = isset($post->user_timezone) ? $post->user_timezone : 'Asia/Manila';
         //ARA set user timezone if any
         if ($post->latitude && $post->longitude) {
             $res = Business::getBusinessByLatitudeLongitude($post->latitude, $post->longitude, $user_timezone);
             // get location first
             if (!count($res)) {
                 $res = Business::all();
             }
         } else {
             $res = Business::all();
         }
         foreach ($res as $count => $data) {
             $first_service = Service::getFirstServiceOfBusiness($data->business_id);
             $all_numbers = ProcessQueue::allNumbers($first_service->service_id);
             $time_open = $data->open_hour . ':' . Helper::doubleZero($data->open_minute) . ' ' . strtoupper($data->open_ampm);
             $time_close = $data->close_hour . ':' . Helper::doubleZero($data->close_minute) . ' ' . strtoupper($data->close_ampm);
             // check if business is currently processing numbers
             if (Business::processingBusinessBool($data->business_id)) {
                 if (Auth::check()) {
                     $processing[] = array('business_id' => $data->business_id, 'business_name' => $data->name, 'local_address' => $data->local_address, 'time_open' => Helper::changeBusinessTimeTimezone($time_open, $data->timezone, $user_timezone), 'time_close' => Helper::changeBusinessTimeTimezone($time_close, $data->timezone, $user_timezone), 'waiting_time' => Analytics::getWaitingTimeString($data->business_id), 'last_number_called' => count($all_numbers->called_numbers) > 0 ? $all_numbers->called_numbers[0]['priority_number'] : 'none', 'next_available_number' => $all_numbers->next_number, 'last_active' => Analytics::getLastActive($data->business_id), 'card_bool' => true);
                 } else {
                     $processing[] = array('business_id' => $data->business_id, 'business_name' => $data->name, 'local_address' => $data->local_address);
                 }
             } else {
                 if (Auth::check()) {
                     $not_processing[] = array('business_id' => $data->business_id, 'business_name' => $data->name, 'local_address' => $data->local_address, 'time_open' => Helper::changeBusinessTimeTimezone($time_open, $data->timezone, $user_timezone), 'time_close' => Helper::changeBusinessTimeTimezone($time_close, $data->timezone, $user_timezone), 'waiting_time' => Analytics::getWaitingTimeString($data->business_id), 'last_number_called' => count($all_numbers->called_numbers) > 0 ? $all_numbers->called_numbers[0]['priority_number'] : 'none', 'next_available_number' => $all_numbers->next_number, 'last_active' => Analytics::getLastActive($data->business_id), 'card_bool' => false);
                 } else {
                     $not_processing[] = array('business_id' => $data->business_id, 'business_name' => $data->name, 'local_address' => $data->local_address);
                 }
             }
         }
         $merged_businesses = array_merge($processing, $not_processing);
         if (Auth::check()) {
             // dashboard business boxes should be 8; known users will be redirected to dashboard
             $merged_businesses = array_slice($merged_businesses, 0, 8);
         } else {
             // homepage business boxes should be only 7 to give space for (more business) box; anon users will be redirected to homepage
             $merged_businesses = array_slice($merged_businesses, 0, 7);
         }
         return json_encode($merged_businesses);
     }
 }