Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lbssousa opened this issue Jun 19, 2020 · 2 comments
Open

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

lbssousa opened this issue Jun 19, 2020 · 2 comments

Comments

@lbssousa
Copy link

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 added a commit that referenced this issue Jun 19, 2020
@tabuna
Copy link
Owner

tabuna commented Jun 19, 2020

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
Copy link
Author

It worked perfectly for me! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants