frontend/controllers/PostController.php
/**
     * 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
     */
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
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
protected function findModel($id)
    {
        $model = Post::find()
            ->andWhere(['id' => $id, 'status' => 'publish'])
            ->andWhere(['<=', 'date', date('Y-m-d H:i:s')])
            ->one();
        if ($model) {
            return $model;
        }
        throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
    }
protected function findModel ( $ id ) { $ model = Post :: find ( ) -> andWhere ( [ 'id' => $ id , 'status' => 'publish' ] ) -> andWhere ( [ '<=' , 'date' , date ( 'Y-m-d H:i:s' ) ] ) -> one ( ) ; if ( $ model ) { return $ model ; } throw new NotFoundHttpException ( Yii :: t ( 'writesdown' , 'The requested page does not exist.' ) ) ; }
Finds the Post model based on its primary key value.
Finds the Post model based on its primary key value .