Skip to content

Instantly share code, notes, and snippets.

@jesseschutt
Created January 21, 2015 02:31
Show Gist options
  • Save jesseschutt/bcca82002ca84bd06fa0 to your computer and use it in GitHub Desktop.
Save jesseschutt/bcca82002ca84bd06fa0 to your computer and use it in GitHub Desktop.
First/Last within Blade Foreach
@foreach( $company->user_tags as $index => $tag)
@if($index == 0)<p><!-- First Time Through -->@endif
<span class="label label-primary">{{ $tag }}</span>
@if($index == count($company->user_tags) - 1) </p> <!-- Last Time Through -->@endif
@endforeach
@jesseschutt
Copy link
Author

Works only if $company->user_tags is a 0 indexed array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment