public function actionDel($id) { $model = new Comment(); $cond = ['or', ['id' => $id], ['pid' => $id]]; $model->deleteAll($cond); // Yii::$app->request->referrer; return $this->redirect(Yii::$app->request->referrer); }
/** * Deletes an existing Comment model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $mode = $this->findModel($id); $post = Post::findOne($mode->post_id); $post->updateCounters(['comment_count' => -1]); $mode->delete(); Comment::deleteAll('parent_id = ' . $id); return $this->redirect(['index']); }
public function actionDelete($id) { if (Yii::$app->user->can('deleteComment')) { $noteId = $this->findComment($id)->note_id; Comment::deleteAll(['id' => CommentClosure::findChildrenIds($id)]); return $this->redirect(['note/view', 'id' => $noteId]); } else { throw new ForbiddenHttpException(); } }
/** * This is invoked after the record is deleted. */ public function afterDelete() { parent::afterDelete(); Comment::deleteAll('post_id = :post_id', [':post_id' => $this->id]); Tag::updateFrequency($this->tags, ''); }
public function afterDelete() { parent::afterDelete(); $Comment = new Comment(); $Comment->deleteAll(['post_id' => $this->id]); $tag = new Tag(); $tag->updateFrequency($this->tags, ''); }
/** * Удаление определенной записи * @param integer $id Идентификатор удаляемой записи * @return redirect */ public function actionDelete($id) { //Определение текущего языка SiteController::locale(); //Поиск задания по идентификатору $task = Task::findOne($id); //Удаление всех связанных с заданием комментариев $commentDeleted = Comment::deleteAll(["task_id" => $id]); if ($task->delete()) { Yii::$app->session->setFlash('success', Yii::t('msg/msg', 'Запись удалена')); return $this->redirect("/"); } else { Yii::$app->session->setFlash('errors', $task->errors); } }
/** * delete post * * @param $id * @throws Exception * @throws NotFoundHttpException * @throws \Exception */ public function actionDelete($id) { try { Yii::trace('Trace :' . __METHOD__, __METHOD__); $model = $this->findModel($id); Comment::deleteAll('post_id = ' . $id); if ($model->delete() === false) { throw new \Exception('Erreur durant la suppression'); } $sidebarCacheName = isset(Yii::$app->params['cache']['sidebar']) ? Yii::$app->params['cache']['sidebar'] : null; if ($sidebarCacheName !== null) { Yii::$app->cache->delete($sidebarCacheName); } return $this->redirect(['/admin/index']); } catch (Exception $e) { Yii::error($e->getMessage(), __METHOD__); throw $e; } }
/** * This is invoked after the record is deleted. */ public function afterDelete() { parent::afterDelete(); Comment::deleteAll(['post_id' => $this->id, 'classify_type' => strtolower($this->getClassName())]); Tag::updateFrequency($this->tags, '', strtolower($this->getClassName())); }