public function actionView($alias, $lang = null, $category = null) { $model = EventsRecord::find()->lang($lang)->joinWith(['category', 'images'])->andWhere([CategoryRecord::tableName() . '.alias' => $category])->andWhere([EventsRecord::tableName() . '.alias' => $alias])->one(); if (!$model) { throw new HttpException('404', 'Запись не найдена'); } return $this->render('view', ['model' => $model]); }
/** * @param $alias * @return self[] */ public static function getFromCategory($alias) { return self::find()->joinWith(['category', 'image'])->lang(\Yii::$app->language)->andWhere([CategoryRecord::tableName() . '.alias' => $alias])->orderBy(['dateCreate' => SORT_DESC])->limit(2)->all(); }