public static function getBreadcrumbs(Request $request)
    {
        $httpPath = $request->segments();
        $menuItems = self::getMenuItems('url');

        $breadcrumbs = array_map(function ($key, $crumb) use ($httpPath, $menuItems) {
            $crumbPath = join('/', array_slice($httpPath, 0, $key + 1));
            $crumbLink = '/' . $crumbPath;

            if (in_array($crumbLink, $menuItems)) {
                return [
                    'link' => $crumbLink,
                    'text' => $menuItems[$crumbLink]->title,
                ];
            }

            return [
                'link' => $crumbLink,
                'text' => str_replace('-', ' ', $crumb),
            ];
        }, array_keys($httpPath), $httpPath);

        $path = '/' . $request->path();
        if (in_array($path, $menuItems)) {
            $crumbs[] = [
                'link' => $menuItems[$path]->url,
                'text' => $menuItems[$path]->title,
            ];

            $breadcrumbs = Breadcrumbs::getNavigationalBreadcrumbs($menuItems[$path]->parent_id, $crumbs);
        }

        array_unshift($breadcrumbs, [
            'link' => env('APP_URL'),
            'text' => 'Home',
        ]);

        return $breadcrumbs;
    }
public static function getBreadcrumbs(Request $request)
    {
        $httpPath = $request->segments();
        $menuItems = self::getMenuItems('url');

        $breadcrumbs = array_map(function ($key, $crumb) use ($httpPath, $menuItems) {
            $crumbPath = join('/', array_slice($httpPath, 0, $key + 1));
            $crumbLink = '/' . $crumbPath;

            if (in_array($crumbLink, $menuItems)) {
                return [
                    'link' => $crumbLink,
                    'text' => $menuItems[$crumbLink]->title,
                ];
            }

            return [
                'link' => $crumbLink,
                'text' => str_replace('-', ' ', $crumb),
            ];
        }, array_keys($httpPath), $httpPath);

        $path = '/' . $request->path();
        if (in_array($path, $menuItems)) {
            $crumbs[] = [
                'link' => $menuItems[$path]->url,
                'text' => $menuItems[$path]->title,
            ];

            $breadcrumbs = Breadcrumbs::getNavigationalBreadcrumbs($menuItems[$path]->parent_id, $crumbs);
        }

        array_unshift($breadcrumbs, [
            'link' => env('APP_URL'),
            'text' => 'Home',
        ]);

        return $breadcrumbs;
    }
public static function getBreadcrumbs ( Request $ request ) { $ httpPath = $ request -> segments ( ) ; $ menuItems = self :: getMenuItems ( 'url' ) ; $ breadcrumbs = array_map ( function ( $ key , $ crumb ) use ( $ httpPath , $ menuItems ) { $ crumbPath = join ( '/' , array_slice ( $ httpPath , 0 , $ key + 1 ) ) ; $ crumbLink = '/' . $ crumbPath ; if ( in_array ( $ crumbLink , $ menuItems ) ) { return [ 'link' => $ crumbLink , 'text' => $ menuItems [ $ crumbLink ] -> title , ] ; } return [ 'link' => $ crumbLink , 'text' => str_replace ( '-' , ' ' , $ crumb ) , ] ; } , array_keys ( $ httpPath ) , $ httpPath ) ; $ path = '/' . $ request -> path ( ) ; if ( in_array ( $ path , $ menuItems ) ) { $ crumbs [ ] = [ 'link' => $ menuItems [ $ path ] -> url , 'text' => $ menuItems [ $ path ] -> title , ] ; $ breadcrumbs = Breadcrumbs :: getNavigationalBreadcrumbs ( $ menuItems [ $ path ] -> parent_id , $ crumbs ) ; } array_unshift ( $ breadcrumbs , [ 'link' => env ( 'APP_URL' ) , 'text' => 'Home' , ] ) ; return $ breadcrumbs ; }
Defines an array of breadcrumbs

@param Request $request
@return array
Defines an array of breadcrumbs