Endpoint
Authentication
This endpoint requires authentication. The user must be logged in to access this endpoint.Path parameters
The ID of the user whose friend request you want to reject. This should be the sender of the friend request.
Behavior
This endpoint removes the friend request relationship where:- The specified user (id) is the sender
- The authenticated user is the receiver
friendsR() relationship, which represents friend requests received by the authenticated user. It detaches the relationship from the friend_requests pivot table.
Response
Success message indicating the request was rejected. Returns
friend_request_rejected.Use case
This endpoint should be used when:- A user wants to decline an incoming friend request
- A user wants to remove a pending request they received without accepting it
/Friend/Request/{id} endpoint, which handles multiple actions including accepting requests and removing friendships.
Examples
Reject a friend request
Reject multiple requests
Implementation details
The endpoint uses Laravel’s EloquentfriendsR() relationship:
friendsR(): Represents friend requests where the authenticated user is the receiver- The relationship is defined in the User model as a
belongsToManyrelationship - Uses the
friend_requestspivot table withrecived_idandsender_idcolumns
- The entry is completely removed from the
friend_requeststable - No status change occurs (unlike accepting, which updates status to ‘accepted’)
- The sender can send a new friend request in the future if desired