Book::find()]); return $this->render('index', [ 'dataProvider' => $dataProvider ]); } public function actionView($id) { /** * @var Book $model */ $model = Book::findOne($id); if ($model == null) { throw new NotFoundHttpException('书不存在'); } $model->addView(); return $this->render('view', [ 'model' => $model ]); } public function actionChapter($id) { /** * @var BookChapter $model */ $model = BookChapter::findOne($id); if ($model == null) { throw new NotFoundHttpException('章节不存在'); } $model->book->addView(); return $this->render('chapter', [ 'model' => $model ]); } }