public function getEventWinners($intEventId)
 {
     if (empty($intEventId)) {
         $intEventId = 1;
     }
     $intEventId = (int) $intEventId;
     //Get all partipant from Event
     $arrParticipants = EventParticipantRead::getParticipantUser($intEventId);
     $eventData = EventRead::getEventDetail($intEventId)[0];
     $intWinnerAmounts = $eventData['total_winner'];
     $arrWinners = self::getRandomWinners($intWinnerAmounts, $arrParticipants);
     // Get Voucher Public key
     $strPublicKey = Event::genPublicKey();
     // Voucher will be created for the winner
     foreach ($arrWinners as $winnerId) {
         $arrVoucherData = array();
         $arrUserVoucher = array();
         // Create voucher
         // Set voucher expired date with the Event Set duration
         $arrVoucherData['event_id'] = $intEventId;
         $arrVoucherData['user_id'] = $winnerId;
         $arrVoucherData['public_key'] = $strPublicKey;
         $arrVoucherData['expired_at'] = self::getExpiredDate($eventData['redeem_duration']);
         // Create voucher with all the detail
         $intVoucherId = VoucherCreate::createVouchers($arrVoucherData);
         // Insert Log into User Voucher table for quick references (voucher id, user_id,created_date
         $arrUserVoucher['user_id'] = $winnerId;
         $arrUserVoucher['voucher_id'] = $intVoucherId;
         UserVoucherCreate::insertUserVoucher($arrUserVoucher);
         // Reset Count for user Participant count to 0
         UserParticipantManage::resetCount($winnerId);
     }
 }
 /**
  * API for event participant
  */
 public function getEventParticipant(Request $request)
 {
     $errors = "";
     $status_code = 200;
     $status = "";
     $result = "";
     $user_id = $request->get('user_id');
     $event_id = $request->get('event_id');
     $public_access_key = $request->query('api_key');
     // Get android callback
     $android_callback = $request->query('caller');
     // If the Api Key is valid
     if (UtilityController::validateApiKey($public_access_key)) {
         /* Future enhance with the weighing measurement
          * Temporary assign all to default value
          */
         $request['weight'] = self::$weight;
         // Validate Event
         $intValidateStatus = EventParticipant::validateParticipantEvent($user_id, $event_id, $result, $error);
         // Done all Validation for user and event
         if ($intValidateStatus == 1) {
             $result = '{"event_id": ' . $event_id . ',"user_id": ' . $user_id . '}';
             // Input into Event Spool
             EventParticipantCreate::participateEvent($request);
             UserParticipantManage::logUserParticipant($user_id);
             $status = true;
         }
     } else {
         // Access Denied detected
         $errors = "Access Denied";
         $status_code = HttpRequest::$ACCESS_DENIED_CODE;
         $status = false;
     }
     $arrResponse = array('api_ver' => self::$API_VERSION, 'caller' => $android_callback, 'error' => $errors, 'status_code' => $status_code, 'status' => $status, 'result' => $result);
     return $arrResponse;
 }