tabuna/breadcrumbs

Support passing data from controller to Breadcrumbs::current()

lbssousa opened this issue · 2 comments

Please provide support for passing data from a Laravel controller to Breadcrumbs::current() in a Blade template, as Breadcrumbs::render() from project https://github.com/davejamesmiller/laravel-breadcrumbs does. It will allow one to avoid calling the same Eloquent model or HTTP request twice (once in controller, and once in route's breadcrumbs() definition).

Hi @lbssousa!
I added expect arguments to the Breadcrumbs::current() method.
Now you can pass there your own variables from the controller:

Route::get('breadcrumbs', function () {
    return Breadcrumbs::current(['value 1', 'value 2', 'value 3'])->toJson();
})
    ->breadcrumbs(function (Trail $trail, $value, $value2, $value3) {
        return $trail
            ->push('Argument', $value)
            ->push('Argument2', $value2)
            ->push('Argument3', $value3);
    });

It worked perfectly for me! Thanks!