getClientIp(); } else { return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp(); } }); // * LOCAL FORCE eg: for Carbon foreach ([\LC_TIME, \LC_MESSAGES, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY] as $category) { setlocale( // * remove numeric to prevent float seperator to breaking numeric transactions $category, \sprintf('%s_%s.UTF-8', config('app.locale'), \strtoupper(config('app.locale'))) ); } Carbon::setLocale(config('app.locale')); // Force bootstrap paginator. Paginator::useBootstrap(); if (!app()->runningInConsole()) { try { View::share('momentFiche', Moments::getCachedStar() ?? false); } catch (\Exception $e) { Log::critical($e->getMessage()); View::share('momentFiche', false); } try { View::share('ActusGlobal', Actu::getCachedActus() ?? []); } catch (\Exception $e) { Log::critical($e->getMessage()); View::share('ActusGlobal', []); } try { View::share('ArticlesGlobal', Articles::getCachedArticles() ?? []); } catch (\Exception $e) { Log::critical($e->getMessage()); View::share('ArticlesGlobal', []); } try { View::share('GeneralConfigGlobal', GeneralConfig::getCachedConfigs() ?? []); } catch (\Exception $e) { Log::critical($e->getMessage()); View::share('GeneralConfigGlobal', []); } // * Instagram Singleton App::singleton('Instagram', function () { return new ApiFetcher(); }); }//end if Blade::directive('svg', function ($arguments) { // Funky madness to accept multiple arguments into the directive. list($path, $class) = array_pad(explode(',', trim($arguments, "() ")), 2, ''); $path = trim($path, "' "); $class = trim($class, "' "); // Create the dom document as per the other answers. $svg = new \DOMDocument(); $svg->load(public_path($path)); $svg->documentElement->setAttribute("class", $class); $output = $svg->saveXML($svg->documentElement); return $output; }); } }