LaravelMessages

Summary

No protected properties found
N/A
No private methods found
No private properties found
N/A
File
messages.php
Package
Default
Class hierarchy
LaravelMessages

Tags

None found

Properties

$messages

$messages : array

All of the registered messages.

Type

array

Tags

None found

$format

$format : string

Default format for message output.

Type

string

Tags

None found

Methods

__construct()

__construct(array  $messages = array()) : void

Create a new Messages instance.

Parameters

array $messages

Tags

None found

add()

add(string  $key, string  $message) : void

Add a message to the collector.

// Add a message for the e-mail attribute $messages->add('email', 'The e-mail address is invalid.');

Parameters

string $key
string $message

Tags

None found

has()

has(string  $key = null) : boolean

Determine if messages exist for a given key.

// Is there a message for the e-mail attribute return $messages->has('email');

// Is there a message for the any attribute
echo $messages->has();

Parameters

string $key

Returns

boolean

Tags

None found

format()

format(string  $format = ':message') 

Set the default message format for output.

// Apply a new default format. $messages->format('email', 'this is my :message

');

Parameters

string $format

Tags

None found

first()

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

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

// Echo the first message out of all messages. echo $messages->first();

// Echo the first message for the e-mail attribute
echo $messages->first('email');

// Format the first message for the e-mail attribute
echo $messages->first('email', '<p>:message</p>');

Parameters

string $key
string $format

Returns

string

Tags

None found

get()

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

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

// Echo all of the messages for the e-mail attribute echo $messages->get('email');

// Format all of the messages for the e-mail attribute
echo $messages->get('email', '<p>:message</p>');

Parameters

string $key
string $format

Returns

array

Tags

None found

all()

all(string  $format = null) : array

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

// Get all of the messages in the collector $all = $messages->all();

// Format all of the messages in the collector
$all = $messages->all('<p>:message</p>');

Parameters

string $format

Returns

array

Tags

None found

unique()

unique(string  $key, string  $message) : boolean

Determine if a key and message combination already exists.

Parameters

string $key
string $message

Returns

boolean

Tags

None found

transform()

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

Format an array of messages.

Parameters

array $messages
string $format

Returns

array

Tags

None found