/** * 伪删除 * @param $id * @return \yii\web\Response * @throws NotFoundHttpException */ public function actionDelete($id) { $model = Tweet::findTweet($id); if (!$model->isCurrent()) { throw new NotFoundHttpException(); } if ($model->comment_count) { $this->flash("已有评论,属于共有财产,不能删除", 'warning'); } else { TweetService::delete($model); $this->flash("删除成功。 ", 'success'); } return $this->redirect(['index']); }
public function userDoAction($id, $action) { $topic = Tweet::findTweet($id); $user = \Yii::$app->user->getIdentity(); return UserService::TopicActionB($user, $topic, $action); }