/**
  * Lists all JackpotDetails models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => JackpotDetails::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
 /**
  * Upcoming Jackpot list Web Service
  * @return mixed
  */
 public function actionApiJackpotUpcomingList()
 {
     $this->layout = false;
     $model = new JackpotDetails();
     header('Content-type: application/json');
     $json = file_get_contents('php://input');
     //convert the string of data to an array
     $data['Jackpot'] = json_decode($json, true);
     //$data['Jackpot'] = Yii::$app->request->post();
     $limit = empty($data['Jackpot']['limit']) ? '20' : $data['Jackpot']['limit'];
     $start = empty($data['Jackpot']['offset']) ? '0' : $data['Jackpot']['offset'];
     if ($start > 0) {
         $start = $start * $limit;
     }
     $jackpotListCount = JackpotDetails::find()->where(['>', 'end_date', date("Y-m-d H:i:s")])->asArray()->all();
     $jackpotList = JackpotDetails::find()->where(['>', 'end_date', date("Y-m-d H:i:s")])->limit($limit)->offset($start)->asArray()->all();
     if (!empty($jackpotList)) {
         $index = 0;
         foreach ($jackpotList as $list) {
             $time = strtotime($list['end_date']) + 3600;
             // Add 1 hour
             $jackpotListNew[$index]['lotteryName'] = $list['name'];
             $jackpotListNew[$index]['lotteryStartDate'] = $list['start_date'];
             $jackpotListNew[$index]['drawDate'] = date("Y-m-d H:i:s", $time);
             $jackpotListNew[$index]['jackpotPrize'] = $list['jackpot_price'];
             $jackpotListNew[$index]['ticketPrize'] = $list['ticket_price'];
             $jackpotListNew[$index]['lotteryImage'] = $list['jackpot_section_image'];
             $jackpotListNew[$index]['countryIcon'] = $list['countryid'] . '.png';
             $index++;
         }
         $return['status'] = 1;
         $return['data'] = $jackpotListNew;
         $return['totalRecords'] = count($jackpotListCount);
         $return['message'] = "Data Retrieved  Successfully.";
         return json_encode($return);
     } else {
         $return['status'] = 0;
         $return['message'] = "There is no Upcoming Jackpot.";
         return json_encode($return);
     }
 }
 /**
  * Lists all Past Jackpots models.
  * @return mixed
  */
 public function actionPast()
 {
     $lastMonth = time() - 3600 * 24 * 30;
     $last_month = date("Y-m-d H:i:s", $lastMonth);
     $dataProvider = new ActiveDataProvider(['query' => JackpotDetails::find()->where(['<', 'end_date', date("Y-m-d H:i:s", time() + 3600)])->andWhere(['>=', 'end_date', $last_month])]);
     return $this->render('past', ['dataProvider' => $dataProvider]);
 }