The syntax of your code seems fine. Are you sure that you are not including this file at a different location, without the method and route?
Laravel Dynamic Breadcrumb Blade page
Hello everyone, i am creating a breadcrumb blade where a breadcrumb will be dynamic for all pages
Firstly in the create, index, edit, trash blade i include
@include('backend.includes.breadcrumb', ['title' => 'users', 'method' => 'edit', 'route' => 'users'])
and in breadcrumb.blade.php
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
<div class="breadcrumb-title pe-3">{{ $title }}</div>
<div class="ps-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb mb-0 p-0">
<li class="breadcrumb-item"><a href="{{ route('backend.dashboard') }}"><i class="bx bx-user"></i></a></li>
<li class="breadcrumb-item"><a href="{{ route('backend.'. $route.'.index') }}">{{ $title }}</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ $method }}</li>
</ol>
</nav>
</div>
<div class="ms-auto">
<div class="btn-group">
<a class="btn btn-primary" href="{{ route('backend.'. $route.'.'. $method .'') }}">Add New</a>
</div>
</div>
</div>
but the problem is, only {{ $title }} value is coming, not others.
it says
Undefined variable $route
Undefined variable $method
How can i solve this issue ? any one ??
@jhyaps You could pass empty values, but I'd personally prefer to not pass them to the view at all. In your breadcrumb template, you could safely check the existence of the variables.
...
@if(isset($title))
<div class="breadcrumb-title pe-3">{{ $title }}</div>
@endif
...
If you introduce new variables in the future, they won't break and you don't have to update all implementations to pass an extra empty value.
Please or to participate in this conversation.