Tips and Tricks

How to create breadcrumbs in Laravel

tips_tricks

In this article, you will learn how to show breadcrumbs on your web application.

This short example is made primarily for Laravel CMS, but you could apply this idea to any web project.

The trick is to simply grab a part of your current page’s URL and show it nicely somewhere at the top of your page.

<div>
	<?php $current_route = request()->route()->getName();
	$breadcrumb = str_replace('.',' / ',$current_route);
	$breadcrumb = ucwords($breadcrumb);
	?>
	<p>{{$breadcrumb}}</p>
</div>