コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = I18nMessage::find()->with('sourceMessageModel')->joinWith('sourceMessageModel');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['{{%i18n_source_message}}.id' => $this->id]);
     $query->andFilterWhere(['like', '{{%i18n_source_message}}.language', $this->language])->andFilterWhere(['like', '{{%i18n_source_message}}.translation', $this->translation])->andFilterWhere(['like', '{{%i18n_source_message}}.message', $this->sourceMessage])->andFilterWhere(['like', '{{%i18n_source_message}}.category', $this->category]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: I18nMessageSearch.php プロジェクト: allhaze/renault
 public static function getForFrontend()
 {
     $query = I18nMessage::find()->with('sourceMessageModel')->joinWith('sourceMessageModel')->andFilterWhere(['like', 'language', explode('-', Yii::$app->language)[0]]);
     return ArrayHelper::map($query->all(), 'sourceMessage', 'translation');
 }
コード例 #3
0
 /**
  * Finds the I18nMessage model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @param string $language
  * @return I18nMessage the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id, $language)
 {
     if (($model = I18nMessage::findOne(['id' => $id, 'language' => $language])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getI18nMessages()
 {
     return $this->hasMany(I18nMessage::className(), ['id' => 'id']);
 }