request = $request; } public function compose(View $view) { $query = $this->request->query(); $path = $this->request->path(); $langs = collect(config('locales')) ->reject(function ($locale) { return Arr::has($locale, 'alias'); }) ->map(function ($locale, $id) use ($query, $path) { $query = array_merge($query, ['lang' => $id]); $locale['url'] = url($path.'?'.http_build_query($query)); return $locale; }); $current = 'locales.'.app()->getLocale(); $view->with([ 'current' => config($current.'.name'), 'langs' => $langs, ]); } }