lavary/laravel-menu — pull request #41 by ghprod (2014-12-03 11:21:02+00:00)
Title: Get ``depth`` from current $item

From looping ``$item->children()`` get current depth by calling ``$item->depth()``

Sample code

```
@foreach($items as $item)

{{ $item->title }}
@if($item->hasChildren())

@include('admin::partials/custom-menu-items', array('items' => $item->children()))

@endif

@endforeach
```

``numToOrdinalWord`` is custom function to replace 1 to first, 2 to second, etc. Not included in this package, just for reference only

```php
if ( ! function_exists('numToOrdinalWord')) {

function numToOrdinalWord($num)
{
$first_word =
array('eth','first','second','third','fouth','fifth','sixth','seventh','eighth','ninth','tenth','elevents','twelfth','thirteenth','fourteenth','fifteenth','sixteenth','seventeenth','eighteenth','nineteenth','twentieth');
$second_word = array('','','twenty','thirty','forty','fifty');

if ($num <= 20)
return $first_word[$num];

$first_num = substr($num,-1,1);
$second_num = substr($num,-2,1);

return str_replace('y-eth','ieth',$second_word[$second_num].'-'.$first_word[$first_num]);
}

}
```