Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
9ab1144f
Commit
9ab1144f
authored
Mar 04, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #379 from jasonlewis/patch-6
Allow no key in $messages->first()
parents
8607fcc9
aac25078
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
messages.php
laravel/messages.php
+7
-2
No files found.
laravel/messages.php
View file @
9ab1144f
...
@@ -64,6 +64,9 @@ class Messages {
...
@@ -64,6 +64,9 @@ class Messages {
* Get the first message from the container for a given key.
* Get the first message from the container for a given key.
*
*
* <code>
* <code>
* // Echo the first message out of all messages.
* echo $messages->first();
*
* // Echo the first message for the e-mail attribute
* // Echo the first message for the e-mail attribute
* echo $messages->first('email');
* echo $messages->first('email');
*
*
...
@@ -75,9 +78,11 @@ class Messages {
...
@@ -75,9 +78,11 @@ class Messages {
* @param string $format
* @param string $format
* @return string
* @return string
*/
*/
public
function
first
(
$key
,
$format
=
':message'
)
public
function
first
(
$key
=
null
,
$format
=
':message'
)
{
{
return
(
count
(
$messages
=
$this
->
get
(
$key
,
$format
))
>
0
)
?
$messages
[
0
]
:
''
;
$messages
=
is_null
(
$key
)
?
$this
->
all
(
$format
)
:
$this
->
get
(
$key
,
$format
);
return
(
count
(
$messages
)
>
0
)
?
$messages
[
0
]
:
''
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment