mercredi 27 janvier 2016

How to share a variable across all views?

I want information about the system locale to be available in every view, so I could highlight whatever language is currently selected by a user. After some googling around, I've found the value-sharing issue addressed at the official documentation. However, after putting the code into boot() like this:

class AppServiceProvider extends ServiceProvider{
    public function boot(){
        view()->share('locale', \Lang::getLocale());
    }
}

the $locale variable, when accessed in views, always holds the default system locale, not the currently selected one. Why?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UqhUqm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire