public function actionUndo($type, $follow) { $userId = Yii::$app->user->id; $model = Follow::findOne(['user_id' => $userId, 'type' => $type, 'follow_id' => $follow]); if ($model !== null) { $model->delete(); } $next = Yii::$app->request->get('next'); if (isset($next)) { return $this->redirect($next); } else { $this->goHome(); } }
public function actionUndo($type, $follow) { $model = Follow::findOne(['user_id' => Yii::$app->user->id, 'type' => $type, 'follow_id' => $follow]); if ($model !== null) { if ($model->delete() && $type == 3) { $topic = Topic::findOne($follow); $topic->follow = $topic->follow - 1; $topic->save(); } } $next = Yii::$app->request->get('next'); if (isset($next)) { return $this->redirect($next); } else { $this->goHome(); } }
?> " class="img-rounded"></td> <?php } ?> <td width="10"></td> <td width="auto" valign="right"> <?php if (Yii::$app->user->isGuest || Yii::$app->user->id != $model->id) { ?> <div class="pull-right text-right"> <?php if (!Yii::$app->user->isGuest) { ?> <?php if (\common\models\Follow::findOne(['user_id' => Yii::$app->user->id, 'follow_id' => $model->id, 'type' => 1]) === null) { ?> <button type="button" class="btn btn-success btn-xs" name="setting-button" onclick="location.href = '/follow/do/1/<?php echo $model->id; ?> ?next=/member/<?php echo $model->username; ?> ';">加入特别关注</button> <?php } else { ?> <button type="button" class="btn btn-default btn-xs" name="setting-button" onclick="location.href = '/follow/undo/1/<?php echo $model->id; ?> ?next=/member/<?php