Example #1
0
 /**
  * Updates an existing Confronto model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->empate == 1) {
             $model->vencedor = null;
         }
         $modelAposta = Aposta::find()->where(['=', 'id_confronto', $model->id])->all();
         foreach ($modelAposta as $item) {
             if ($item->placar_casa == $model->placar_casa && $item->placar_visitante == $model->placar_visitante) {
                 $modelRank = new Rank();
                 $modelRank->id_user = $item->id_user;
                 $modelRank->data = date('Y-m-d H:i:s');
                 $modelRank->id_aposta = $item->id;
                 $modelRank->id_ponto = 1;
                 $modelRank->save();
             } else {
                 if ($model->vencedor != null) {
                     if ($item->placar_casa > $item->placar_visitante && $model->vencedor == $model->id_time_casa) {
                         $modelRank = new Rank();
                         $modelRank->id_user = $item->id_user;
                         $modelRank->data = date('Y-m-d H:i:s');
                         $modelRank->id_aposta = $item->id;
                         $modelRank->id_ponto = 2;
                         $modelRank->save();
                     } else {
                         if ($item->placar_casa < $item->placar_visitante && $model->vencedor == $model->id_time_visitante) {
                             $modelRank = new Rank();
                             $modelRank->id_user = $item->id_user;
                             $modelRank->data = date('Y-m-d H:i:s');
                             $modelRank->id_aposta = $item->id;
                             $modelRank->id_ponto = 2;
                             $modelRank->save();
                         }
                     }
                 } else {
                     if ($item->placar_casa == $item->placar_visitante && $model->placar_casa == $model->placar_visitante) {
                         $modelRank = new Rank();
                         $modelRank->id_user = $item->id_user;
                         $modelRank->data = date('Y-m-d H:i:s');
                         $modelRank->id_aposta = $item->id;
                         $modelRank->id_ponto = 2;
                         $modelRank->save();
                     }
                 }
             }
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
 }
Example #2
0
 /**
  * Finds the Aposta model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Aposta the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Aposta::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public static function GetNumeroApostaVisitante($id)
 {
     $model = new Aposta();
     $model = Aposta::find()->where(['=', 'id_confronto', $id])->all();
     $conta = 0;
     foreach ($model as $item) {
         if ($item->placar_casa < $item->placar_visitante) {
             $conta = $conta + 1;
         }
     }
     return $conta;
 }
Example #4
0
    ?>
" />
                                <input type="hidden" id="data" name="data" value="<?php 
    echo date("Y-m-d H:i:s");
    ?>
" />

                            </form>
                           
                        </div> 
                        <div id="verApostaDiv-<?php 
    echo $data->id;
    ?>
" class="panel-body verApostaDiv">
                            <?php 
    $apostas = Aposta::find()->where(['=', 'id_confronto', $data->id])->orderBy(['data' => SORT_DESC])->all();
    ?>
                            <?php 
    foreach ($apostas as $aposta) {
        ?>

                                <div class="divApostas_<?php 
        echo $aposta->id;
        ?>
" style="padding: 0 0px 0px 2.5%;;
                                     margin: -30px 0 12px  0; text-align: right;width: 162px;">

                                    <div class="" style="width: 30%;display: initial;">
                                        <label>
                                            <?php 
        echo ucfirst($aposta->idUser->username);
Example #5
0
 public static function GetErros($id)
 {
     $modelAposta = Rank::find()->where(['=', 'id_user', $id])->all();
     $model = Aposta::find()->where(['=', 'id_user', $id])->all();
     $total = 0;
     $totalAposta = 0;
     foreach ($modelAposta as $item) {
         $total = $total + 1;
     }
     foreach ($model as $item) {
         $totalAposta = $totalAposta + 1;
     }
     return $totalAposta - $total;
 }