Table structure and query for messaging between users I'm building a PHP Laravel app and one of the features is messaging between users. A user can message other users. 

This is my current schema: 

I'm trying to achieve the following:- 

Have a list of conversations between different users on a page with the last message between users. 
The first column should be the participant's name. This is the query I'm using currently:

SELECT * FROM messages WHERE id IN (SELECT MAX(id) FROM messages WHERE sender_id = $current_user_id OR recipient_id =$current_user_id GROUP BY conversation_id)

which gives me the result in screenshot (Note: The first column is the sender's id so this is incorrect for now). 
I have a col in messages table :conversation_id which I'm using to group the messages. I set this value in php while inserting message, based on the 2 participants' id, eg. 1_2. this is calculated using: "smaller_id_number"_"bigger_id_number". This makes sure that the conversation id between 2 users will always be same. Whether they sent or received the message. I think this is not the best approach so I'm open to alternative suggestions to achieve what I'm trying to where I don't have to use a redundant (as per my thoughts) column conversation_id. 

On a side note. I also have a single page for conversations between 2 users where users can see all messages between them and the participant. I'm using this query for that: 

SELECT * FROM messages WHERE conversation_id='1_3'

Then on php side, I check if the message was sent or received by current user by checking the sender_id. So if I get a solution for my problem above without using conversation_id, I might need to update this feature as well.

Any help is appreciated. Thanks.

P.S. I have checked similar questions but they are not answering my problem.

EDIT:
To clarify, I'm only asking one question here.

Current sample data
These are the messages. My goal is to get a list of last messages between a user and other users(highlighted in yellow) and the participant's name. I will query using the current user's id on recipient_id or sender_id 

Current results with my new query:
SELECT m.*, u1.name AS sender, u2.name AS recipient
FROM messages m
JOIN users u1 ON m.sender_id=u1.id
JOIN users u2 ON m.recipient_id=u2.id
WHERE m.id IN (
SELECT MAX(id)
FROM messages
WHERE sender_id = 1 OR recipient_id =1
GROUP BY conversation_id) ORDER BY m.id DESC



I am able to get the participant name in PHP by checking if the current user's id is the sender's id. If yes then I set the participant name to recipient. If not then sender.

As you can see, I have to use php to get the participant name. My goal is to get the participant in MYSQL, if possible. And to eliminate the extra column conversation_id that I'm using if it would be possible without it because I also have to generate this first in php before inserting new message. 

Expected output:
For your main question:

You should be able to use a case statement to get just the other person's name:

SELECT m.*, CASE WHEN u2.id = 1
              THEN u1.name
              ELSE u2.name
            END as participant
FROM messages m
JOIN users u1 ON m.sender_id=u1.id
JOIN users u2 ON m.recipient_id=u2.id
WHERE m.id IN (
SELECT MAX(id)
FROM messages
WHERE sender_id = 1 OR recipient_id =1
GROUP BY conversation_id) ORDER BY m.id DESC
;


If the user id from u2 is the ID of the user whose information you're retrieving, then you want the name from u1. Otherwise, you want the name from u2. This should work even if users can send messages to themselves.