Search code examples
phplaravellaravel-4breadcrumbs

Breadcrumbs error in Laravel


I'm trying to use the breadcrumbs by davejamesmiller

In the breadcrumbs.php file which is in the same directory as of route.php I have setup up this:

<?php

Breadcrumbs::register('courses', function($breadcrumbs) {
    $breadcrumbs->push('Courses', route('courses')); });

and in the route.php I have:

Route::get('/courses', 'CoursesController@index');

and in the courses.index I called the breadcrumbs like this:

{{ Breadcrumbs::render('courses') }}

But I'm getting an error as follows:

Route [courses] not defined. (View: C:\wamp\www\lc2\laravel\app\views\courses\index.blade.php)

What might be the problem? I cant seem to figure out. I already have the route set for the courses.


Solution

  • i think you have to use laravel named routes - documentation , also in github repo readme

    Route::get('/courses', ['uses' => 'CoursesController@index', 'as' => 'courses']);