コード例 #1
0
    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Against2::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,
            'factor' => $this->factor,
            'optional' => $this->optional,
        ]);

        $query->andFilterWhere(['ilike', 'factor_code', $this->factor_code])
            ->andFilterWhere(['ilike', 'name', $this->name]);

        return $dataProvider;
    }
コード例 #2
0
 /**
  * Finds the Against2 model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Against2 the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Against2::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: Factors2.php プロジェクト: ellinn7/openprofosmotr
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAgainsts()
 {
     return $this->hasMany(Against2::className(), ['factor' => 'id']);
 }
コード例 #4
0
 protected static function addAgainsts($againsts_arr, $factor_group, $factor)
 {
     if ($factor_group == 1) {
         $againsts = Against1::find()->where(['factor' => $factor])->all();
     } else {
         $againsts = Against2::find()->where(['factor' => $factor])->all();
     }
     if ($againsts) {
         foreach ($againsts as $against) {
             $againsts_arr[] = $against->name;
         }
     }
     return $againsts_arr;
 }