/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DotaPlayerRole::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]);
 }
Exemple #3
0
    <?//= $form->field($model, 'timecreated')->textInput() ?>

    <?//= $form->field($model, 'avatar')->textInput(['maxlength' => true]) ?>

    <?//= $form->field($model, 'avatarmedium')->textInput(['maxlength' => true]) ?>

    <?//= $form->field($model, 'avatarfull')->textInput(['maxlength' => true]) ?>

    <?//= $form->field($model, 'country_id')->textInput() ?>
    <?php 
echo $form->field($model, 'country_id')->dropDownList(Country::getLeaguesListDropDown(), [$model->country_id]);
?>
    
    <?php 
echo $form->field($model, 'role_id')->dropDownList(DotaPlayerRole::getRolesListDropDown(), [$model->role_id]);
?>
    
    <?php 
echo $form->field($model, 'status')->dropDownList($model->statusValues, [$model->status]);
?>
    
    <?php 
echo $form->field($model, 'imageFiles')->fileInput();
?>
    <?php 
if ($model->foto != '') {
    ?>
    	<div class="form-group">
    		<?php 
    echo Html::img(DImageHelper::getImageUrl($model->foto, 'players'));
 /**
  * Finds the DotaPlayerRole model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DotaPlayerRole the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DotaPlayerRole::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRole()
 {
     return $this->hasOne(DotaPlayerRole::className(), ['id' => 'role_id']);
 }