Skip to content

[5.4] Add getSection to view factory#19213

Merged
taylorotwell merged 5 commits into
laravel:5.4from
VinceG:view-get-section
May 15, 2017
Merged

[5.4] Add getSection to view factory#19213
taylorotwell merged 5 commits into
laravel:5.4from
VinceG:view-get-section

Conversation

@VinceG
Copy link
Copy Markdown
Contributor

@VinceG VinceG commented May 15, 2017

We currently have getSections and hasSection, it just makes sense to also have getSection. In practice this comes handy since right now we have to do something like this in views:

@if(count(View::getSections()['actions']))

or

@foreach(View::getSections()['actions'] as $i => $item)

This is a small addition that can make it a little bit cleaner and easier to understand.

The above will be translated to

@foreach(View::getSection('actions') as $i => $item)

the second parameter $default allows to handle those cases when that section does not exist at all and use a default.

Thank You.

@tillkruss tillkruss changed the title Add getSection to view factory [5.4] Add getSection to view factory May 15, 2017
@taylorotwell taylorotwell merged commit 7d19bfc into laravel:5.4 May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants