protected function findModel($id) { if (($model = Post::findOne($id)) !== null) { /** @var Post $model */ return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }