It depends where in the request cycle you want this to be set and where you want this data to be accessed. Most of the times putting it in the boot method of the AppServiceProvider will do, but sometimes it should better be placed in a route middleware (for example if you want to be able to group routes for multilanguage setup).
The following SO question has two answers, one with an example using a ServiceProvider and another using a Middleware.
http://stackoverflow.com/questions/28356193/laravel-5-share-variables-in-service-providers
filter in laravel 5 change to middleware, you can read :
http://stackoverflow.com/questions/26373850/filters-in-laravel-5 http://mattstauffer.co/blog/laravel-5.0-middleware-filter-style
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community