Menu

## ConversationMessages extends Component
in package

ConversationMessages.php : 24

Class ConversationMessages

Livewire component responsible for displaying and dynamically updating messages within a specific conversation.

This component handles:

- Initial message collection injection
- Listening for real-time message creation events
- Prepending new messages to the message list

### Table of Contents

#### Properties

$conversationId : int|string
  Conversation identifier.
$messages : Collection
  Collection of conversation messages.

#### Methods

getListeners() : array<string|int, mixed>
  Register Livewire event listeners.
mount() : void
  Lifecycle hook executed when the component is mounted.
prependMessage() : void
  Prepend a message to the message list.
prependMessageFromBroadcast() : void
  Handle broadcasted message creation event.
render() : View
  Render the Livewire component view.

### Properties

#### $conversationId

ConversationMessages.php : 38

Conversation identifier.

`public int|string $conversationId`

#### $messages

ConversationMessages.php : 31

Collection of conversation messages.

`public Collection $messages`

### Methods

#### getListeners()

ConversationMessages.php : 66

Register Livewire event listeners.

`public getListeners() : array<string|int, mixed>`

Listens for:

- Local message creation events
- Broadcasted message creation events on the conversation private channel

##### Return values

array<string|int, mixed>

#### mount()

ConversationMessages.php : 50

Lifecycle hook executed when the component is mounted.

`public mount(Conversation $conversation, Collection $messages) : void`

Injects the conversation instance and the initial message collection.

##### Parameters

$conversation : Conversation
$messages : Collection

#### prependMessage()

ConversationMessages.php : 84

Prepend a message to the message list.

`public prependMessage(int|string $id) : void`

Fetches the message by ID and adds it to the beginning of the collection.

##### Parameters

$id : int|string

  Message ID

#### prependMessageFromBroadcast()

ConversationMessages.php : 98

Handle broadcasted message creation event.

`public prependMessageFromBroadcast(array<string|int, mixed> $payload) : void`

Extracts the message ID from the payload and prepends the message to the list.

##### Parameters

$payload : array<string|int, mixed>

  Broadcast event payload

#### render()

ConversationMessages.php : 110

Render the Livewire component view.

`public render() : View`

Displays the conversation messages list.

##### Return values

View

## Search results