Breadcrumb grouping (Breadcrumbs::group())
robjbrain opened this issue · 3 comments
I've been using this for a while and really like it, but thought i'd suggest a couple of improvements.
It would be awesome if you could add breadcrumb grouping like how laravel does route grouping.
Something like this:
Breadcrumbs::group(array('parent' => 'admin'), function($breadcrumbs) {
Breadcrumbs::register('users', function($breadcrumbs)
{
$breadcrumbs->users('Users', URL::to('admin/users'));
});
})
That way you don't have to constantly write $breadcrumbs->parent('admin') for every single admin page (or $breadcrumbs->parent('home') for that matter)
I personally like to be explicit about it, but I wouldn't oppose adding this if someone wants to write it.
Something to think about: Where would you put children of the 'users' route? Assuming they're inside the group too, you could end up with 'admin' being displayed twice, since now technically it's a parent of both breadcrumbs - unless there is some code to prevent that.
You could also have another option for 'prefix':
Breadcrumbs::register('admin', function($breadcrumbs) {
$breadcrumbs->push('Admin', URL::to('admin'));
});
Breadcrumbs::group(['prefix' => 'admin', 'parent' => 'admin'], function($breadcrumbs)
{
Breadcrumbs::register('users', function($breadcrumbs) {
$breadcrumbs->push('Users', URL::to('admin/users'));
});
Breadcrumbs::register('users.edit', function($breadcrumbs, $user) {
$breadcrumbs->parent('admin.users');
$breadcrumbs->push('Users', URL::to('admin/users/edit/' . $user->id));
});
});
The downside of that is it's no longer easy to see where 'admin.users' is defined.
Just some things to think about if you (or someone else) decide to do a PR.
@robjbrain suggestion is right and it should be implemented for breadcrumb.That will help us to group all like routes
Laravel Breadcrumbs is no longer officially maintained
Please see the README file for further details.