MessageBag
class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, MessageBag, MessageProvider
Properties
protected array | $messages | All of the registered messages. |
|
protected string | $format | Default format for message output. |
Methods
Create a new message bag instance.
Get the keys present in the message bag.
Add a message to the bag.
Determine if a key and message combination already exists.
Determine if messages exist for all of the given keys.
Determine if messages exist for any of the given keys.
Get the first message from the bag for a given key.
Get all of the messages from the bag for a given key.
Get the messages for a wildcard key.
Get all of the messages for every key in the bag.
Get all of the unique messages for every key in the bag.
Format an array of messages.
Get the appropriate format based on the given format.
Get the raw messages in the container.
Get the raw messages in the container.
Get the messages for the instance.
Get the default message format.
Set the default message format.
Determine if the message bag has any messages.
Determine if the message bag has any messages.
Get the number of messages in the container.
Get the instance as an array.
Convert the object into something JSON serializable.
Convert the object to its JSON representation.
Convert the message bag to its string representation.
Details
at line 34
void
__construct(array $messages = [])
Create a new message bag instance.
at line 46
array
keys()
Get the keys present in the message bag.
at line 58
$this
add(string $key, string $message)
Add a message to the bag.
at line 74
protected bool
isUnique(string $key, string $message)
Determine if a key and message combination already exists.
at line 87
$this
merge(MessageProvider|array $messages)
Merge a new array of messages into the bag.
at line 104
bool
has(string|array $key)
Determine if messages exist for all of the given keys.
at line 127
bool
hasAny(array|string $keys = [])
Determine if messages exist for any of the given keys.
at line 147
string
first(string $key = null, string $format = null)
Get the first message from the bag for a given key.
at line 163
array
get(string $key, string $format = null)
Get all of the messages from the bag for a given key.
at line 188
protected array
getMessagesForWildcardKey(string $key, string|null $format)
Get the messages for a wildcard key.
at line 207
array
all(string $format = null)
Get all of the messages for every key in the bag.
at line 226
array
unique(string $format = null)
Get all of the unique messages for every key in the bag.
at line 239
protected array
transform(array $messages, string $format, string $messageKey)
Format an array of messages.
at line 256
protected string
checkFormat(string $format)
Get the appropriate format based on the given format.
at line 266
array
messages()
Get the raw messages in the container.
at line 276
array
getMessages()
Get the raw messages in the container.
at line 286
MessageBag
getMessageBag()
Get the messages for the instance.
at line 296
string
getFormat()
Get the default message format.
at line 307
$this
setFormat(string $format = ':message')
Set the default message format.
at line 319
bool
isEmpty()
Determine if the message bag has any messages.
at line 329
bool
any()
Determine if the message bag has any messages.
at line 339
int
count()
Get the number of messages in the container.
at line 349
array
toArray()
Get the instance as an array.
at line 359
array
jsonSerialize()
Convert the object into something JSON serializable.
at line 370
string
toJson(int $options = 0)
Convert the object to its JSON representation.
at line 380
string
__toString()
Convert the message bag to its string representation.