protected function findModel($id) { if (($model = Blog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Deletes an existing Blog model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = Blog::findOne($id); if ($model) { $model->delete(); } return $this->redirect(['index']); }
public function actionBlogDetail($id) { $data = $this->getCommonDate(); $modelGoodsCategories = GoodsCategory::find()->all(); $modelBanner = Banner::find()->where(['status' => 0])->all(); $modelBrends = Brend::find()->all(); $modelBlog = Blog::findOne($id); $modelBlogComents = BlogComments::getComentsByBlogId($id); return $this->render('blog-detail', ['modelBlog' => $modelBlog, 'data' => $data, 'modelGoodsCategories' => $modelGoodsCategories, 'modelBrends' => $modelBrends, 'modelBanner' => $modelBanner, 'modelBlogComents' => $modelBlogComents]); }