findTweet() public static method

通过ID获取指定动弹
public static findTweet ( $id ) : array | Topic | null | ActiveRecord
$id
return array | Topic | null | yii\db\ActiveRecord
Beispiel #1
0
 /**
  * 伪删除
  * @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']);
 }
Beispiel #2
0
 public function userDoAction($id, $action)
 {
     $topic = Tweet::findTweet($id);
     $user = \Yii::$app->user->getIdentity();
     return UserService::TopicActionB($user, $topic, $action);
 }