Skip to content

Instantly share code, notes, and snippets.

@michaelaguiar
Last active December 22, 2015 09:49
Show Gist options
  • Save michaelaguiar/6454935 to your computer and use it in GitHub Desktop.
Save michaelaguiar/6454935 to your computer and use it in GitHub Desktop.
Breadcrumbs for Laravel
<div class="breadcrumbs">
<a href="/home">Home</a>
<?php
if (!URI::is('home')) {
$arrayURI = explode('/', URI::current());
foreach ($arrayURI as $key => $value) {
$url = '';
for ($i = 0; $i <= $key; $i++) {
$url .= $arrayURI[$i].'/';
}
if ($key === (count($arrayURI) - 1)) {
echo '<span class="separator"></span><span>'.ucwords(str_replace('-', ' ', $value)).'</span>';
} else {
echo '<span class="separator"></span><a href="/'.$url.'">'.ucwords(str_replace('-', ' ', $value)).'</a>';
}
}
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment