Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AdditionalFieldRecord::find();
     if (!isset($params['sort'])) {
         $query->orderBy(['label' => SORT_ASC]);
     }
     $session = Yii::$app->session;
     if (!$session['language_id']) {
         $session['language_id'] = LanguageRecord::getMainLanguageId();
     }
     $query->andWhere(['language_id' => $session['language_id']]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAdditionalField()
 {
     return $this->hasOne(AdditionalFieldRecord::className(), ['id' => 'additional_field_id']);
 }
 /**
  * Finds the AdditionalField record model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AdditionalFieldRecord the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AdditionalFieldRecord::findOne($id)) !== null) {
         return $model;
     }
     throw new NotFoundHttpException(Yii::t('back', 'The requested page does not exist.'));
 }