@php use Illuminate\Support\Facades\Route; use Illuminate\Support\Str; $route = request()->route(); $routeName = $route?->getName(); // e.g. "nearby.index", "nearby.settings" $breadcrumbs = []; // Always start with Home if (Route::has('dashboard')) { $breadcrumbs[] = [ 'label' => __('Dashboard'), 'url' => route('dashboard'), ]; } if ($routeName && $routeName !== 'dashboard') { // slug = first part before "." $slug = Str::before($routeName, '.'); // "nearby" from "nearby.index" // If the route name starts with "{slug}*" we consider it a module route if ($slug && Route::is($slug . '*')) { $key = "modules.$slug.name"; $label = __($key); // Fallback if no translation if ($label === $key) { $label = Str::headline($slug); // "nearby" -> "Nearby" } } else { // Non-module routes: breadcrumbs.{routeName} or fallback $key = "breadcrumbs.$routeName"; $label = __($key); if ($label === $key) { $label = Str::headline(str_replace('.', ' ', $routeName)); } } if (!empty($label)) { $breadcrumbs[] = [ 'label' => $label, 'url' => null, ]; } } @endphp @if (count($breadcrumbs) > 0)