diff --git a/backend/controllers/BookController.php b/backend/controllers/BookController.php index 21da149..c136e04 100644 --- a/backend/controllers/BookController.php +++ b/backend/controllers/BookController.php @@ -143,6 +143,20 @@ return $this->redirect([ 'index' ]); } + public function deleteModel($id) + { + $book = Book::find() + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + + + return $book->delete(); + } + public static function removeDirectory($dir) { if ($objs = glob($dir . "/*")) { diff --git a/backend/views/comment/_form.php b/backend/views/comment/_form.php index 268da67..9c1db0c 100644 --- a/backend/views/comment/_form.php +++ b/backend/views/comment/_form.php @@ -29,7 +29,11 @@ JS;
- book->title?> + entityObject !== null){ + echo $model->entityObject->title; + } + ?> field($model, 'name') ->textInput([ 'maxlength' => true ]) ?> diff --git a/common/models/Comment.php b/common/models/Comment.php index 3cb1f8c..d1e6323 100644 --- a/common/models/Comment.php +++ b/common/models/Comment.php @@ -127,4 +127,11 @@ public function getActiveComments(){ return $this->getComments()->where(['status' => true]); } + + public function getEntityObject(){ + if ($this->entity !== null){ + return $this->hasOne($this->entity, ['id' => 'entity_id']); + } + return null; + } } -- libgit2 0.21.4