/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DotaHeroRole::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'ratio' => $this->ratio]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 public function actionStat()
 {
     $current_action = Yii::$app->controller->action->id;
     $fantasy_type = Yii::$app->request->get('type', 'all');
     $current_filter_for = Yii::$app->request->get('for', 'players');
     $current_filter_year = Yii::$app->request->get('year', 'all');
     $current_filter_league = Yii::$app->request->get('league', 'all');
     switch ($current_filter_for) {
         case 'players':
             $searchModel = new DotaMatchHistoryPlayersSearch();
             $roles_ratios = DotaPlayerRole::getRolesListRatios();
             break;
         case 'heroes':
             $searchModel = new DotaMatchHistoryHeroesSearch();
             $roles_ratios = DotaHeroRole::getRolesListRatios();
             break;
         default:
             throw new BadRequestHttpException('Bad Request');
             break;
     }
     $sort = $searchModel->getSort($current_filter_for);
     $dataProvider = $searchModel->searchStatRows($current_filter_for, $current_filter_year, $current_filter_league, $sort);
     $params = DotaParams::loadParams();
     //echo'<pre>'; print_r($roles_ratios);echo'</pre>';die;
     /*
     foreach($dataProvider->models as $model) {
     	switch($current_filter_for) {
     		case 'players':
     			$scores = ($model['level'] * $roles_ratios[$model['role_id']]) + ($model['kills'] * $params['ratio_kills']) + ($model['deaths'] * $params['ratio_deaths']) + ($model['assists'] * $params['ratio_assists']) + ($model['gold_per_min'] * $params['ratio_gold_per_min']) + ($model['xp_per_min'] * $params['ratio_xp_per_min']);
     			break;
     		case 'heroes':
     			$scores = ($model['level'] * $roles_ratios[$model['role_id']]) + ($model['kills'] * $params['ratio_kills']) + ($model['deaths'] * $params['ratio_deaths']) + ($model['assists'] * $params['ratio_assists']) + ($model['gold_per_min'] * $params['ratio_gold_per_min']) + ($model['xp_per_min'] * $params['ratio_xp_per_min']);
     			break;
     	}
     
     	//echo'<pre>'; print_r($scores);echo'</pre>';//die;
     
     	$model['scores'] = $scores;
     }
     */
     return $this->render('stat', ['current_action' => $current_action, 'fantasy_type' => $fantasy_type, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'sort' => $sort, 'current_filter_for' => $current_filter_for, 'current_filter_year' => $current_filter_year, 'current_filter_league' => $current_filter_league, 'roles_ratios' => $roles_ratios, 'params' => $params]);
 }
 /**
  * Finds the DotaHeroRole model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DotaHeroRole the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DotaHeroRole::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
echo $form->field($model, 'id')->textInput(['disabled' => 'disabled']);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true, 'disabled' => 'disabled']);
?>

    <?php 
echo $form->field($model, 'localized_name')->textInput(['maxlength' => true]);
?>
    
    <?php 
echo $form->field($model, 'status')->dropDownList($model->statusValues, [$model->status]);
?>
    
    <?php 
echo $form->field($model, 'role_id')->dropDownList(DotaHeroRole::getRolesListDropDown(), [$model->role_id]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>