Skip to content

A simple blade extension for foreach (supports laravel 4.2+).

Notifications You must be signed in to change notification settings

apollopy/blade-xforeach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BladeXForeach

A simple blade extension for foreach (supports laravel 4.2+).

Installation

Requirements

"php": ">=5.4.0",
"illuminate/support": "4.2.*"

Composer

  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/apollopy/blade-xforeach.git"
    }
  ],
  "require": {
    "apollopy/blade-xforeach": "v1.3"
  }

Add the service provider in app/config/app.php:

'ApolloPY\BladeXForeach\ServiceProvider'

Example

@foreach ($arr as $key => $val)
    @if ( @isforeachfirst($val) )
        first
    @endif

    key = {{ $key }}
    val = {{ $val }}

    {{ @foreachindex($val) }} <!-- int, starts at 0 -->
    
    {{ @foreachiteration($val) }} <!-- int, starts at 1 -->

    @if ( @isforeachlast($val) )
        end
    @endif
    
    @continue
    @break
@endforeach

About

A simple blade extension for foreach (supports laravel 4.2+).

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages