public function getDateAdmissionAttribute() { $now = new Carbon(); $dt = new Carbon($this->created_at); $dt->setLocale('es'); return $dt->diffForHumans($now); }
public function __construct() { // Carbon Language Carbon::setLocale('tr'); // create home page if non exist count(Menu::where('slug', '/anasayfa')->get()) == 0 ? Menu::create(['title' => 'Anasayfa', 'slug' => '/anasayfa', 'eng_title' => 'Home', 'eng_slug' => '/home'])->save() : null; // create config file if non exist !\File::exists(storage_path('.config')) ? \File::put(storage_path('.config'), json_encode(['brand' => 'Brand Name', 'mail' => '*****@*****.**', 'active' => 1, 'eng' => '0', 'one_page' => '0', 'googlemap' => '', 'header' => ''])) : null; $this->config = json_decode(\File::get(storage_path('.config'))); !\File::exists(storage_path('app/custom/css')) ? \File::makeDirectory(storage_path('app/custom/css'), 0755, true) : null; !\File::exists(storage_path('app/custom/js')) ? \File::makeDirectory(storage_path('app/custom/js'), 0755, true) : null; // get css & js files from custom folder // css $css = \File::allFiles(storage_path('app/custom/css')); if (!empty($css)) { foreach ($css as $cs) { $this->css[$cs->getCtime()] = $cs->getRelativePathname(); } // sort by date ksort($this->css); } // js $js = \File::allFiles(storage_path('app/custom/js')); if (!empty($js)) { foreach ($js as $j) { $this->js[$j->getCtime()] = $j->getRelativePathname(); } // sort by date ksort($this->js); } }
/** * @internal param UserRepositoryInterface $userRepository */ public function __construct() { $this->middleware('auth'); $this->middleware('hasOrganization', ['except' => ['index', 'create', 'store']]); $this->organization = Auth::user()->organization()->first(); Carbon::setLocale('fr'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { /** * Locale is enabled and allowed to be changed */ if (config('locale.status')) { if (session()->has('locale') && in_array(session()->get('locale'), array_keys(config('locale.languages')))) { /** * Set the Laravel locale */ app()->setLocale(session()->get('locale')); /** * setLocale for php. Enables ->formatLocalized() with localized values for dates */ setLocale(LC_TIME, config('locale.languages')[session()->get('locale')][1]); /** * setLocale to use Carbon source locales. Enables diffForHumans() localized */ Carbon::setLocale(config('locale.languages')[session()->get('locale')][0]); /** * Set the session variable for whether or not the app is using RTL support * for the current language being selected * For use in the blade directive in BladeServiceProvider */ if (config('locale.languages')[session()->get('locale')][2]) { session(['lang-rtl' => true]); } else { session()->forget('lang-rtl'); } } } return $next($request); }
public function boot() { view()->composer('*', function ($view) { $view->with('authenticatedUser', Auth::user()); }); Carbon::setLocale('fr'); }
public function index() { Carbon::setLocale('de'); setlocale(LC_TIME, 'de_DE.utf8'); $myTipps = Tipp::join('matches', 'tipps.match_id', '=', 'matches.id')->join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->select('matches.home_goals as erg1', 'matches.away_goals as erg2', 'matches.date', 'tipps.*', 'homeclub.club as home', 'awayclub.club as away')->where('tipps.user_id', '=', Auth::id())->orderBy('date')->get(); return view('pages.tipps', compact('myTipps')); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // get supported locales $supportedLocales = LaravelLocalization::getSupportedLocales(); // 1. get current locale $locale = LaravelLocalization::getCurrentLocale(); // 2. check from session $sessionLocale = session('someline-locale'); if (!empty($sessionLocale)) { // if supported if (is_array($supportedLocales) && isset($supportedLocales[$sessionLocale])) { $locale = $sessionLocale; } } // 3. check from lang $lang = $request->get('lang'); if (!empty($lang)) { // if supported if (is_array($supportedLocales) && isset($supportedLocales[$lang])) { $locale = $lang; } } // set locale LaravelLocalization::setLocale($locale); // set carbon locale Carbon::setLocale($locale); return $next($request); }
/** * Controller constructor. */ public function __construct() { // load base JS JavaScript::put(['csrf_token' => csrf_token(), 'base_url' => url('/'), 'app_name' => config('settings.app_name_' . config('app.locale')), 'loading_spinner' => config('settings.loading_spinner'), 'success_icon' => config('settings.success_icon'), 'error_icon' => config('settings.error_icon'), 'info_icon' => config('settings.info_icon'), 'locale' => config('app.locale'), 'multilingual' => config('settings.multilingual')]); // load modal if an alert is waiting if (session()->get('alert')) { JavaScript::put(['modal_alert' => true]); } // we set the og meta title $this->og_meta['og:site_name'] = config('settings.app_name_' . config('app.locale')); // we manage the locale dependencies switch (config('app.locale')) { case 'fr': // server locale setlocale(LC_TIME, 'fr_FR.UTF-8'); // carbon locale Carbon::setLocale('fr'); // og locale $this->og_meta['og:locale'] = 'fr_FR'; break; case 'en': // server locale setlocale(LC_TIME, 'en_GB.UTF-8'); // carbon locale Carbon::setLocale('en'); // og locale $this->og_meta['og:locale'] = 'en_GB'; break; } }
/** * */ public function __construct() { Carbon::setLocale('es'); view()->share('background', $this->setBackground()); view()->share('main_menu', $this->mainMenu()); view()->share('admin_menu', $this->adminMenu()); }
/** * Bootstrap any application services. * * @return void */ public function boot() { /** * Application locale defaults for various components * * These will be overridden by LocaleMiddleware if the session local is set */ /** * setLocale for php. Enables ->formatLocalized() with localized values for dates */ setLocale(LC_TIME, config('app.locale_php')); /** * setLocale to use Carbon source locales. Enables diffForHumans() localized */ Carbon::setLocale(config('app.locale')); /** * Set the session variable for whether or not the app is using RTL support * For use in the blade directive in BladeServiceProvider */ if (config('locale.languages')[config('app.locale')][2]) { session(['lang-rtl' => true]); } else { session()->forget('lang-rtl'); } }
/** * Controller constructor. */ public function __construct() { View::share('hideBudgets', false); View::share('hideCategories', false); View::share('hideBills', false); View::share('hideTags', false); if (Auth::check()) { $pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US')); $lang = $pref->data; $this->monthFormat = (string) trans('config.month'); $this->monthAndDayFormat = (string) trans('config.month_and_day'); App::setLocale($lang); Carbon::setLocale(substr($lang, 0, 2)); $locale = explode(',', trans('config.locale')); $locale = array_map('trim', $locale); setlocale(LC_TIME, $locale); setlocale(LC_MONETARY, $locale); // change localeconv to a new array: $numberFormatter = numfmt_create($lang, NumberFormatter::CURRENCY); $localeconv = ['mon_decimal_point' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)), 'mon_thousands_sep' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL)), 'frac_digits' => $numberFormatter->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)]; View::share('monthFormat', $this->monthFormat); View::share('monthAndDayFormat', $this->monthAndDayFormat); View::share('language', $lang); View::share('localeconv', $localeconv); } }
public function __construct() { $this->middleware('auth'); $this->middleware('hasOrganization'); $this->organization = Auth::user()->organization()->first(); Carbon::setLocale('fr'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('auth/login'); } } /** @var User $user */ $user = $this->auth->user(); if ($user instanceof User && intval($user->blocked) == 1) { Auth::logout(); return redirect()->route('index'); } // if logged in, set user language: $pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US')); App::setLocale($pref->data); Carbon::setLocale(substr($pref->data, 0, 2)); $locale = explode(',', trans('config.locale')); $locale = array_map('trim', $locale); setlocale(LC_TIME, $locale); setlocale(LC_MONETARY, $locale); return $next($request); }
/** * Set the default locale. * * @param string $locale * @return void */ public function setLocale($locale) { $this->locale = $locale; // setlocale(LC_ALL, $locale); Carbon::setLocale($locale); }
public function __construct() { // Set Carbon locale Carbon::setLocale(app()->getLocale()); // Share current locale to Views view()->share('locale', app()->getLocale()); }
/** * Bootstrap any application services. * * @return void */ public function boot() { if ($locale = request()->cookie('locale__myProject')) { app()->setLocale(\Crypt::decrypt($locale)); } \Carbon\Carbon::setLocale(app()->getLocale()); }
/** * Bootstrap any application services. * * @return void */ public function boot() { /* * Seteo del locale para las fechas */ Carbon::setLocale(config('app.locale')); }
protected function loadConfigs() { Carbon::setLocale(config('app.locale')); date_default_timezone_set(config('app.timezone')); setlocale(LC_ALL, config('app.locale') . '.utf8'); config(['auth.providers.users.model' => \Mixdinternet\Admix\User::class]); $this->mergeConfigFrom(__DIR__ . '/../config/admin.php', 'admin'); }
public function setLocale(Locale $locale) { static::$locale = $locale; app()->setLocale($locale->iso6391()); setlocale(LC_ALL, $locale->locale()); Carbon::setLocale($locale->iso6391()); return $this; }
/** * Bootstrap any application services. * * @return void */ public function boot() { if ($locale = Request::cookie('locale')) { $locale = Crypt::decrypt($locale); app()->setLocale($locale); Carbon::setLocale($locale); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { setlocale(LC_TIME, config('app.locale')); Carbon::setLocale('fr'); ini_set('memory_limit', '2048M'); ini_set('max_execution_time', 300); return $next($request); }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->setupBlade(); // App::setLocale(''); Carbon::setLocale(config('app.locale')); require __DIR__ . '/../assets.php'; require __DIR__ . '/../listeners.php'; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $locale = $request->cookie('locale', Config::get('app.locale')); App::setLocale($locale); Carbon::setLocale($locale); Carbon::setToStringFormat('Y-m-d H:i:s'); return $next($request); }
/** * @internal param UserRepositoryInterface $userRepository */ public function __construct(CrmService $crmService) { $this->middleware('auth'); $this->middleware('hasOrganization'); $this->crmService = $crmService; $this->organization = Auth::user()->organization()->first(); $this->crm = $this->organization->crm()->first(); Carbon::setLocale('fr'); }
protected function setCarbonLocale() { $locale = env('APP_LOCALE', 'en'); if (file_exists(base_path("vendor/nesbot/carbon/src/Carbon/Lang/{$locale}.php"))) { Carbon::setLocale($locale); } else { Carbon::setLocale('en'); } }
public function index() { \Carbon\Carbon::setLocale('bg'); $mail = MailStore::orderBy('created_at', 'desc')->where('trash', '=', false)->get(); foreach ($mail as $key => $message) { $mail[$key]['time'] = $message->created_at->diffForHumans(); } return view('admin.mail.index', ['mail' => $mail]); }
/** * Set locale * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $language = Session::get('language', Config::get('app.locale')); $current_lang = Language::whereCode($language)->firstOrFail(); App::setLocale($language); Carbon::setLocale($language); Session::set('current_lang', $current_lang); return $next($request); }
/** * Register any application services. * * @return void */ public function register() { //Faker with pt_BR Language $this->app->singleton(FakerGenerator::class, function () { return FakerFactory::create('pt_BR'); }); //Translate Carbon diff for humans Carbon::setLocale($this->app->getLocale()); }
/** * Set the carbon locale. */ private function setLocale() { // Get the locale from the app config file. $locale = $this->config->get('app.locale'); // Check if it is set and not empty. if (isset($locale) && !empty($locale)) { // Set the carbon locale. $this->carbon->setLocale($locale); } }
public function checkNotifications() { Carbon::setLocale('ja'); $notifications = $this->getNotification(\Auth::user()->id); $notificationsTimeAgo = array_map(function ($e) { $h = Carbon::parse($e->notify_created_at); return $h->diffForHumans(); }, $notifications); return compact('notifications', 'notificationsTimeAgo'); }