Closed tutkun closed 6 years ago
Sorry for being late. I forgot to reply your question.
Each message belongs to one user (the sender): $message->sender
.
To get all messages in a particular thread, with senders, use this:
/**
* List all messages.
*
* @param \Gerardjbaez\Messenger\Models\MessageThread $thread
* @return Response
*/
function all(MessageThread $thread)
{
// This will load all messages with sender
$thread->load('messages.sender');
return response()->json([
'messages' => $thread->messages->toArray()
]);
}
To get one message with sender, use this:
/**
* Show a message.
*
* @param \Gerardjbaez\Messenger\Models\Message $message
* @return Response
*/
function show(Message $message)
{
// This will load sender
$message->load('message.sender');
return response()->json([
'message' => $message->toArray()
]);
}
Hey, thanks for this pack!
How I get the messages with sender for vuejs?
I use:
but, i want that is like;