Level 9
Find a solution, but I don't know if it's good practice
public function boot() {
//did not work here <-------
view()->composer('*', function (View $view) {
$locale = App::getLocale();
Carbon::setUtf8(true);
Carbon::setLocale($locale);
if ($locale === 'en') {
$cities = City::pluck('name_en', 'id');
$shopTypes = ShopType::pluck('name_en', 'id');
$categories = Category::pluck('name_en', 'id');
} else {
$cities = City::pluck('name_ar', 'id');
$shopTypes = ShopType::pluck('name_ar', 'id');
$categories = Category::pluck('name_ar', 'id');
}
$view->with('cities', $cities);
$view->with('shopTypes', $shopTypes);
$view->with('categories', $categories);
});
}