Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Add getSection to view factory #19213

Merged
merged 5 commits into from
May 15, 2017
Merged

[5.4] Add getSection to view factory #19213

merged 5 commits into from
May 15, 2017

Conversation

VinceG
Copy link
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