55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Pagination\Paginator;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
// !!! Fuc**** Lab LDC exception OMG !!!
|
|
if (!in_array(config('app.env'), ['local', 'testing'])) {
|
|
URL::forceRootUrl(config('app.url'));
|
|
\Illuminate\Pagination\AbstractPaginator::currentPathResolver(function () {
|
|
/** @var \Illuminate\Routing\UrlGenerator $url */
|
|
$url = app('url');
|
|
return $url->current();
|
|
});
|
|
}
|
|
// * LOCAL HTTPS FIX
|
|
if (!in_array(config('app.env'), ['local', 'testing'])) {
|
|
URL::forceScheme('https');
|
|
}
|
|
// * HA PROXY FIX
|
|
App::singleton('clientIp', function () {
|
|
if (config('app.env') == 'local') {
|
|
return request()->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'));
|
|
if (!app()->runningInConsole()) {
|
|
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
|
|
Paginator::useBootstrap();
|
|
}//end if
|
|
}
|
|
}
|