protected function findModel($id) { if (($model = Content::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionIndex($id) { Content::updateAllCounters(['views' => 1], ['id' => $id]); $model = Content::findOne(['id' => $id]); return $this->render('index', ['model' => $model]); }