public function actionFriends() { $id = Yii::$app->request->post('id'); $action = Yii::$app->request->post('action'); Yii::trace($id . ' ' . $action); if ($id != null && $action != null) { if ($action == 'addto') { QueryModel::addTo($id); } else { QueryModel::deleteFrom($id); } $isFriend = QueryModel::isFriend($id); if ($isFriend == null) { return '<a>' . Yii::t('app', 'Добавить в друзья') . '</a>'; } elseif ($isFriend['to'] != null && $isFriend['from'] == null) { return '<a>' . Yii::t('app', 'Отозвать заявку') . '</a>'; } else { return '<a>' . Yii::t('app', 'Удалить из друзей') . '</a>'; } } return '123'; }
public function actionFriends() { if (Yii::$app->request->isPost) { QueryModel::addTo(Yii::$app->request->get('id')); } $new = QueryModel::newFriends(); $add = QueryModel::addFriends(); $friends = QueryModel::friends(); return $this->render('friends', ['friends' => $friends, 'new' => $new, 'add' => $add]); }