class Illuminate / Support / MessageBag

MessageBag

Implements

Properties

protected

$messages array

All of the registered messages.

Default: []
protected

$format string

Default format for message output.

Default: ':message'

Methods

public

__construct ( array $messages ) : void

Create a new message bag instance.

Parameters

  • $messages array
public

keys ( ) : array

Get the keys present in the message bag.

public

add ( $key , $message ) : $this

Add a message to the message bag.

Parameters

  • $key string
  • $message string
public

addIf ( $boolean , $key , $message ) : $this

Add a message to the message bag if the given conditional is "true".

Parameters

  • $boolean bool
  • $key string
  • $message string
protected

isUnique ( $key , $message ) : bool

Determine if a key and message combination already exists.

Parameters

  • $key string
  • $message string
public

merge ( $messages ) : $this

Merge a new array of messages into the message bag.

Parameters

public

has ( $key ) : bool

Determine if messages exist for all of the given keys.

Parameters

  • $key array|string|null
public

hasAny ( $keys ) : bool

Determine if messages exist for any of the given keys.

Parameters

  • $keys array|string|null
public

first ( $key , $format ) : string

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

Parameters

  • $key string|null
  • $format string|null
public

get ( $key , $format ) : array

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

Parameters

  • $key string
  • $format string|null
protected

getMessagesForWildcardKey ( $key , $format ) : array

Get the messages for a wildcard key.

Parameters

  • $key string
  • $format string|null
public

all ( $format ) : array

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

Parameters

  • $format string|null
public

unique ( $format ) : array

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

Parameters

  • $format string|null
public

forget ( $key ) : $this

Remove a message from the message bag.

Parameters

  • $key string
protected

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

Format an array of messages.

Parameters

  • $messages array
  • $format string
  • $messageKey string
protected

checkFormat ( $format ) : string

Get the appropriate format based on the given format.

Parameters

  • $format string
public

messages ( ) : array

Get the raw messages in the message bag.

public

getMessages ( ) : array

Get the raw messages in the message bag.

public

getMessageBag ( ) : MessageBag

Get the messages for the instance.

public

getFormat ( ) : string

Get the default message format.

public

setFormat ( $format ) : MessageBag

Set the default message format.

Parameters

  • $format string
public

isEmpty ( ) : bool

Determine if the message bag has any messages.

public

isNotEmpty ( ) : bool

Determine if the message bag has any messages.

public

any ( ) : bool

Determine if the message bag has any messages.

public

count ( ) : int

Get the number of messages in the message bag.

public

toArray ( ) : array

Get the instance as an array.

public

jsonSerialize ( ) : array

Convert the object into something JSON serializable.

public

toJson ( $options ) : string

Convert the object to its JSON representation.

Parameters

  • $options int
public

__toString ( ) : string

Convert the message bag to its string representation.