MessageBag

interface MessageBag implements Arrayable (View source)

Methods

array toArray()

Get the instance as an array.

from Arrayable
array keys()

Get the keys present in the message bag.

$this add(string $key, string $message)

Add a message to the bag.

$this merge(MessageProvider|array $messages)

Merge a new array of messages into the bag.

bool has(string|array $key)

Determine if messages exist for a given key.

string first(string|null $key = null, string|null $format = null)

Get the first message from the bag for a given key.

array get(string $key, string|null $format = null)

Get all of the messages from the bag for a given key.

array all(string|null $format = null)

Get all of the messages for every key in the bag.

array getMessages()

Get the raw messages in the container.

string getFormat()

Get the default message format.

$this setFormat(string $format = ':message')

Set the default message format.

bool isEmpty()

Determine if the message bag has any messages.

bool isNotEmpty()

Determine if the message bag has any messages.

int count()

Get the number of messages in the container.

Details

array toArray()

Get the instance as an array.

Return Value

array

array keys()

Get the keys present in the message bag.

Return Value

array

$this add(string $key, string $message)

Add a message to the bag.

Parameters

string $key
string $message

Return Value

$this

$this merge(MessageProvider|array $messages)

Merge a new array of messages into the bag.

Parameters

MessageProvider|array $messages

Return Value

$this

bool has(string|array $key)

Determine if messages exist for a given key.

Parameters

string|array $key

Return Value

bool

string first(string|null $key = null, string|null $format = null)

Get the first message from the bag for a given key.

Parameters

string|null $key
string|null $format

Return Value

string

array get(string $key, string|null $format = null)

Get all of the messages from the bag for a given key.

Parameters

string $key
string|null $format

Return Value

array

array all(string|null $format = null)

Get all of the messages for every key in the bag.

Parameters

string|null $format

Return Value

array

array getMessages()

Get the raw messages in the container.

Return Value

array

string getFormat()

Get the default message format.

Return Value

string

$this setFormat(string $format = ':message')

Set the default message format.

Parameters

string $format

Return Value

$this

bool isEmpty()

Determine if the message bag has any messages.

Return Value

bool

bool isNotEmpty()

Determine if the message bag has any messages.

Return Value

bool

int count()

Get the number of messages in the container.

Return Value

int

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Contracts/Support/MessageBag.html