Search code examples
phplaravel-4breadcrumbs

Making first letter uppercase in Laravel breadcrumbs


Is there a function or something in laravel which I can use to make first letter uppercase in breadcrumbs?

This is what I'm using right now but in my links and routes are all lowercase letters and if I go and try to update all will be very time consuming..

<ul class="breadcrumb">
<li>
     <i class="glyphicon glyphicon-home"></i>
     <a href="{{ URL::to('/') }}">Home</a> /
     @for($i = 0; $i <= count(Request::segments()); $i++)
         <a href="">{{Request::segment($i)}}</a>
         @if($i < count(Request::segments()) & $i > 0)
              /
         @endif
</li>
     @endfor
</ul>

Or this isn't correct way of making breadcrumbs in laravel 4.2?


Solution

  • You can make it with ucfirst very easily

    <ul class="breadcrumb">
        <li>
          <i class="glyphicon glyphicon-home"></i>
          <a href="{{ URL::to('/') }}">Home</a> /
            @for($i = 0; $i <= count(Request::segments()); $i++)
              <a href="">{{ucfirst(Request::segment($i))}}</a>
              @if($i < count(Request::segments()) & $i > 0)
                /
              @endif
        </li>
            @endfor
        </ul>