Ejemplo n.º 1
0
 public function translated()
 {
     $messageTableName = Message::tableName();
     $query = Message::find()->select($messageTableName . '.id');
     $i = 0;
     foreach (Module::getInstallLanguages() as $language) {
         if ($i === 0) {
             $query->andWhere($messageTableName . '.language = :language and ' . $messageTableName . '.translation is not null', [':language' => $language]);
         } else {
             $query->innerJoin($messageTableName . ' t' . $i, 't' . $i . '.id = ' . $messageTableName . '.id and t' . $i . '.language = :language and t' . $i . '.translation is not null', [':language' => $language]);
         }
         $i++;
     }
     $ids = $query->indexBy('id')->all();
     $this->andWhere(['in', 'id', array_keys($ids)]);
     return $this;
 }
Ejemplo n.º 2
0
 public function getMessages()
 {
     return $this->hasMany(Message::className(), ['id' => 'id'])->indexBy('language');
 }