diglactic / laravel-breadcrumbs

Laravel Breadcrumbs - A simple Laravel-style way to create breadcrumbs.
https://packagist.org/packages/diglactic/laravel-breadcrumbs
MIT License
868 stars 63 forks source link

[Question] Get a list of all registered breadcrumbs #71

Closed itCarl closed 1 year ago

itCarl commented 1 year ago

Hello there, 👋 first of all I really like this package for laravel. ❤️ Most of all I love the simplicity.

Is there a possibility to get all registered breadcrumbs as collection or array?

Why I ask? In my project I have a feedback page where the user can send feedback on various areas/topics. and to better specify the area the user can select in a dropdown field the area in which he wants to give feedback. Now it would be very handy if this list would be equal to the display of the breadcrumbs.

I would really apprechiate it if you could help me with my question.

shengslogar commented 1 year ago

Great question and use case! There is no way to get a list of registered breadcrumbs as an array. You might consider two alternatives:

  1. Looping over a set of routes and calling Breadcrumbs::exists('route-name')
  2. Storing your breadcrumbs in an array that both your feedback page and breadcrumbs.php can access and then registering breadcrumbs (Breadcrumbs::for) from your array

I hope that helps!