Support passing data from controller to Breadcrumbs::current()
lbssousa opened this issue · 2 comments
lbssousa commented
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).
tabuna commented
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);
});
lbssousa commented
It worked perfectly for me! Thanks!