@php $urlPath = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/')); $baseUrl = url('/'); $breadcrumbs = [ (object) [ 'title' => 'Home', 'url' => $baseUrl ] ]; foreach ($urlPath as $index => $segment) { $title = ucwords(str_replace('-', ' ', $segment)); $urlSegment = implode('/', array_slice($urlPath, 0, $index + 1)); if ($index + 1 !== count($urlPath) && $index > 0) { $urlSegment = "product-category/" . implode('/', array_slice($urlPath, 1, $index)); } $url = $index === count($urlPath) - 1 ? null : url($urlSegment); $breadcrumbs[] = (object) [ 'title' => $title, 'url' => $url ]; } @endphp @unless (empty($breadcrumbs)) @endunless