public function actionSendFriendRequestAsFamily() { if (isset($_POST['user_id_1']) && isset($_POST['user_id_2']) && isset($_POST['create_at'])) { // Notification $notify = new RelationshipNotification(); $notify['action_id'] = $_POST['user_id_1']; $notify['receive_id'] = $_POST['user_id_2']; $user_id_1 = $_POST['user_id_1']; $user_id_2 = $_POST['user_id_2']; $rel = new Relationship(); $rel['user_id_action'] = $user_id_1; if ($user_id_1 > $user_id_2) { $tg = $user_id_1; $user_id_1 = $user_id_2; $user_id_2 = $tg; $rel['with_user_2_is'] = 2; } else { $rel['with_user_1_is'] = 2; } $rel['user_id_1'] = $user_id_1; $rel['user_id_2'] = $user_id_2; $rel['status'] = 0; $rel['create_at'] = $_POST['create_at']; $rel->save(); $notify['type'] = 1; $notify['status'] = 0; $notify['create_at'] = $_POST['create_at']; $notify->save(); echo '<a id="add_friend_btn" class="btn btn-primary btn-block disabled"><b>Đã gửi yêu cầu</b></a>'; } else { echo 'NO'; } }
public static function addPending($user_id_1, $user_id_2) { $relationship = new Relationship(); $relationship['user_id_action'] = $user_id_1; if ($user_id_1 > $user_id_2) { $temp = $user_id_1; $user_id_1 = $user_id_2; $user_id_2 = $temp; } $relationship['user_id_1'] = $user_id_1; $relationship['user_id_2'] = $user_id_2; $relationship['status'] = 0; $relationship->save(); }