All good. There is the following query:
$chat_list = ChatModel::where('creator', session()->get('id')) ->orWhere('reciever', session()->get('id')) ->get();
We get a list of all the messages in the chat, you need to group for individual chats with users. I already broke my head how to build a query, from my ideas - add an identifier to the chat. I ask for your help.
id(int primary key), creator(int), reciever(int), text(text), created_at(datetime)
. I thought about adding a chat identifier, then using thegroupBy
method - Vladislav