コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Games::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->innerJoin(Groups::tableName(), Groups::tableName() . '.id=group_id');
     $query->andFilterWhere(['id' => $this->id, 'group_id' => $this->group_id, 'cost' => $this->cost, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', Groups::tableName() . '.name', $this->groupname]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the Groups model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Groups the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Groups::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: Games.php プロジェクト: numbnp/random_steam_keys
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGroup()
 {
     return $this->hasOne(Groups::className(), ['id' => 'group_id']);
 }
コード例 #4
0
ファイル: _form.php プロジェクト: numbnp/random_steam_keys
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use backend\models\Groups;
/* @var $this yii\web\View */
/* @var $model backend\models\Games */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="games-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
$groups = Groups::find()->all();
$items = ArrayHelper::map($groups, 'id', 'name');
$params = ['prompt' => 'Укажите группу'];
?>
    <?php 
echo $form->field($model, 'group_id')->dropDownList($items, $params);
?>

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

    <?php 
echo $form->field($model, 'cost')->textInput();
?>