public function actionJoinToClub() { $request = Yii::$app->request; $clubId = $request->post('clubId'); if (Club::isGuest($clubId, Yii::$app->user->getId()) && !Club::isPotentialMembers($clubId, Yii::$app->user->getId())) { $status = Club::joinToClub($clubId, Yii::$app->user->getId()); echo json_encode(['status' => $status]); return; } echo json_encode(['error' => 'error']); }