Example of View composers in tighten/onramp

File app/Providers/ViewServiceProvider.php (link to Github)
use App\Facades\Localization;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class ViewServiceProvider extends ServiceProvider
{
    public function boot()
    {
        View::composer('partials.language-switcher', function ($view) {
            $view->with([
                'locales' => Localization::all(),
                'language' => Localization::languageForLocale(locale()),
            ]);
        });
    }
}
File resources/views/partials/language-switcher.blade.php (link to Github)
<language-switcher
    language="{{ $language }}"
    :languages="{{ json_encode($locales) }}">
</language-switcher>

Additional resources on view composers: