-
Notifications
You must be signed in to change notification settings - Fork 416
Conversation
Have you verified that caching would actually speed it up? As discussed in #112 I have my doubts, but I'd like to see some benchmarks. |
The primary target is a better structure. I have more than 50 definitions in my breadcrumbs.php. |
OK so ignoring the caching/speed issue, I think:
So that would give us something like this, with no // routes/web.php
Route::get('forums/category/{category}', ['as' => 'forums.category',
'uses' => 'ForumsController@category', 'breadcrumb' => 'ForumsBreadcrumbs@category']);
// app/Http/Breadcrumbs/ForumsBreadcrumbs.php
namespace App\Http\Breadcrumbs;
use App\Models\Category;
use DaveJamesMiller\Breadcrumbs\Breadcrumbs;
class ForumsBreadcrumbs extends Breadcrumbs
{
public function category(Category $category)
{
$this->parent('home'); // Uses the 'home' route
//OR $this->parent('HomeBreadcrumbs@index');
$this->push($category->title, route('forums.category', $category->id));
}
} What do you think? |
That is a really cool idea. I have implemented it. TODO:
|
better namespace handling fix parseRoutes remove debug infos fix unit tests
443a663
to
bff3808
Compare
Now supported: <?php
/**
* The breadcrumbs.php
**/
Breadcrumbs::register('AAA', function($breadcrumbs, $param)
{
$breadcrumbs->push('Home - ' . $param, '');
});
Breadcrumbs::register('BBB', 'BBBBBreadcrumbs@add');
Breadcrumbs::register('CCC', '\Foo\Bar\CCCCBreadcrumbs@add') # routes.php
Route::get('forums/category/{category}', ['as' => 'forums.category',
'uses' => 'ForumsController@category', 'breadcrumb' => 'ForumsBreadcrumbs@category']);
Route::get('forums/category/{category}', ['as' => 'forums.category',
'uses' => 'ForumsController@category', 'breadcrumb' => '\Foo\Bar\ForumsBreadcrumbs@category']); |
Thanks for this. Just wanted to update you - my current thought is to include this in the next major version, as it's a big change. I may make it the default and deprecate the old way - I need to think about that more and experiment with it on my own projects to see which feels more natural. And the documentation will need updating to explain how to use it. I don't expect I'll have time to do that for several weeks - say late October. One more thing I want to look into - it seems in Laravel 5.3 the |
Laravel Breadcrumbs is no longer officially maintained |
Sorry, I've decided I no longer have the time or motivation to continue supporting this package, so I won't be merging this. Thanks for taking the time to implement it though - hopefully someone will fork the package and consider including this. Another option I thought of is to keep the old |
@davejamesmiller could you create last issue where people can decide who will fork and maintain your package? |
Add support for string classes (like routes)
This is the first step for cached Breadcrumbs.
Example: breadcrumbs.php
Example: ProjectBreadcrumbController