Baton registers a global view composer which will enable passing of the Baton collection to all views. The Baton collection contains all named routes (optional) as well as any additional values you wish to add to the collection prior to rendering the view.
If you are looking for a more flexible package which is specifically designed to pass only named routes to the client I would
composer require jshannon63/laravel-baton
Laravel 5.5+ will automatically take care of the service provider registration.
Baton will by default pass named routes to the rendered view. If you wish to disable this action, add the following line to your .env file.
BATON_ROUTES=false// Disable returning named routes in Baton
By default, Baton contains a collection of named routes called "routes":
Adding additional data to Baton before passing on to the view
Baton is an extension of the Collection class. You may add, manuipulate or remove any collection elements using the methods of Illuminate\Support\Collection.
Example to add a Blog article to Baton:
First, create a real time Facade for Baton as follows
Then access the put method of Baton using the Facade.
Baton::put( 'article', Blog::find(1) );
Rendering Baton data in a view