コード例 #1
0
ファイル: DefaultController.php プロジェクト: ivphpan/iris
 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]);
 }
コード例 #2
0
 /**
  * @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();
 }