コード例 #1
0
 /**
  * @param $id
  * @return null|static
  * @throws NotFoundHttpException
  */
 protected function findModel($id)
 {
     if (($model = News::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
ファイル: DefaultController.php プロジェクト: BoBRoID/new.k-z
 public function actionGet($newsID)
 {
     $news = News::findOne($newsID);
     if (empty($news)) {
         throw new NotFoundHttpException("Не найдена новость с идентификатором {$newsID}");
     }
     if (\Yii::$app->request->isAjax) {
         \Yii::$app->session->setFlash('updated', 'Список комментариев обновлён!');
     }
     return $this->renderPartial('comments', ['news' => $news, 'comments' => new ActiveDataProvider(['query' => $news->getComments()->with('votes'), 'sort' => ['defaultOrder' => ['date' => SORT_ASC]]])]);
 }
コード例 #3
0
ファイル: SiteController.php プロジェクト: BoBRoID/new.k-z
 public function actionRedaktsiya()
 {
     $news = News::findOne(['id' => '20819']);
     return $this->actionNews($news->id, true);
 }
コード例 #4
0
ファイル: SiteController.php プロジェクト: kotmonstr/gitar
 public function actionNewsDetail($id)
 {
     $modelSocial = Social::findOne(1);
     $model = News::findOne($id);
     return $this->render('news-detail', ['model' => $model, 'modelSocial' => $modelSocial]);
 }