public function send(Conversation $conversation, $body, $userId, $type = 'text')
    {
        $message = $conversation->messages()->create([
            'body' => $body,
            'user_id' => $userId,
            'type' => $type,
        ]);

        $messageWasSent = Chat::sentMessageEvent();
        $message->load('sender');
        $this->raise(new $messageWasSent($message));

        return $message;
    }
public function send(Conversation $conversation, $body, $userId, $type = 'text')
    {
        $message = $conversation->messages()->create([
            'body' => $body,
            'user_id' => $userId,
            'type' => $type,
        ]);

        $messageWasSent = Chat::sentMessageEvent();
        $message->load('sender');
        $this->raise(new $messageWasSent($message));

        return $message;
    }
public function send ( Conversation $ conversation , $ body , $ userId , $ type = 'text' ) { $ message = $ conversation -> messages ( ) -> create ( [ 'body' => $ body , 'user_id' => $ userId , 'type' => $ type , ] ) ; $ messageWasSent = Chat :: sentMessageEvent ( ) ; $ message -> load ( 'sender' ) ; $ this -> raise ( new $ messageWasSent ( $ message ) ) ; return $ message ; }
Adds a message to a conversation.

@param Conversation $conversation
@param string       $body
@param int          $userId
@param string       $type

@return Message
Adds a message to a conversation .