Beispiel #1
0
 public function findLastXtranslations($lng, $id, $x = 5)
 {
     Translate::setTableName($lng);
     if (($model = Translate::find()->where(['between', 'id', $id - $x, $id - 1])->select(['id', 'str'])) !== null) {
         return $model->limit($x)->orderBy('id DESC')->all();
     } else {
         //            return $this->redirect(['main']);
         throw new NotFoundHttpException('need more vars' . PHP_EOL . $lng . PHP_EOL . $id);
     }
 }
 protected function getTranslationModels($lng, $id)
 {
     Translate::setTableName($lng);
     if (($model = Translate::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException("cant find {$lng} #{$id}");
     }
 }