MessageBag

class MessageBag implements ArrayableInterface, Countable, JsonableInterface, MessageProviderInterface, JsonSerializable (View source)

Properties

protected array $messages All of the registered messages.
protected string $format Default format for message output.

Methods

void __construct(array $messages = array())

Create a new message bag instance.

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

Add a message to the bag.

$this merge(MessageProviderInterface|array $messages)

Merge a new array of messages into the bag.

bool isUnique(string $key, string $message)

Determine if a key and message combination already exists.

bool has(string $key = null)

Determine if messages exist for a given key.

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

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

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

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

array all(string $format = null)

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

array transform(array $messages, string $format, string $messageKey)

Format an array of messages.

string checkFormat(string $format)

Get the appropriate format based on the given format.

array getMessages()

Get the raw messages in the container.

MessageBag getMessageBag()

Get the messages for the instance.

string getFormat()

Get the default message format.

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

Set the default message format.

bool isEmpty()

Determine if the message bag has any messages.

bool any()

Determine if the message bag has any messages.

int count()

Get the number of messages in the container.

array toArray()

Get the instance as an array.

array jsonSerialize()

Convert the object into something JSON serializable.

string toJson(int $options)

Convert the object to its JSON representation.

string __toString()

Convert the message bag to its string representation.

Details

void __construct(array $messages = array())

Create a new message bag instance.

Parameters

array $messages

Return Value

void

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

Add a message to the bag.

Parameters

string $key
string $message

Return Value

$this

$this merge(MessageProviderInterface|array $messages)

Merge a new array of messages into the bag.

Parameters

MessageProviderInterface|array $messages

Return Value

$this

protected bool isUnique(string $key, string $message)

Determine if a key and message combination already exists.

Parameters

string $key
string $message

Return Value

bool

bool has(string $key = null)

Determine if messages exist for a given key.

Parameters

string $key

Return Value

bool

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

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

Parameters

string $key
string $format

Return Value

string

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

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

Parameters

string $key
string $format

Return Value

array

array all(string $format = null)

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

Parameters

string $format

Return Value

array

protected array transform(array $messages, string $format, string $messageKey)

Format an array of messages.

Parameters

array $messages
string $format
string $messageKey

Return Value

array

protected string checkFormat(string $format)

Get the appropriate format based on the given format.

Parameters

string $format

Return Value

string

array getMessages()

Get the raw messages in the container.

Return Value

array

MessageBag getMessageBag()

Get the messages for the instance.

Return Value

MessageBag

string getFormat()

Get the default message format.

Return Value

string

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

Set the default message format.

Parameters

string $format

Return Value

MessageBag

bool isEmpty()

Determine if the message bag has any messages.

Return Value

bool

bool any()

Determine if the message bag has any messages.

Return Value

bool

int count()

Get the number of messages in the container.

Return Value

int

array toArray()

Get the instance as an array.

Return Value

array

array jsonSerialize()

Convert the object into something JSON serializable.

Return Value

array

string toJson(int $options)

Convert the object to its JSON representation.

Parameters

int $options

Return Value

string

string __toString()

Convert the message bag to its string representation.

Return Value

string

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