Esempio n. 1
0
 public function actionShow($title)
 {
     $post = \frontend\models\Post::findOne(['title' => $title]);
     return $this->render('/site/show_post', ['model' => $post]);
 }
Esempio n. 2
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 public function findModel($id)
 {
     if (($model = Post::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
 public function actionPost($id)
 {
     $post = Post::findOne(['id' => $id]);
     return $this->render('post', ['post' => $post]);
 }