ldc-jeusselin/app/Providers/AppServiceProvider.php
Jérémy Munsch de4dcfb283
Closes #2 and #4
- Add status checker + admin secure packages + upgrade enum + add sentry + upgrade to sitemap generator + bump to CRMV2
- Set customer role enum and user role enum
- Update customer migration to set roles
- phpcbf
- faker local to fr
- update lang
- composer update
- bump laravel ui
- Redo all user crud
- npm bump
- Create admin command
- rearrange views
- redo all auth system
- redo customer pro bo
2023-08-21 15:43:33 +02:00

84 lines
2.4 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Prevent lazy loading, but only when the app is not in production.
Model::preventLazyLoading(config('app.env') !== 'production');
// * HTTPS FIX
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
setlocale(LC_ALL, \sprintf(
'%s_%s.UTF-8',
config('app.locale'),
\strtoupper(config('app.locale'))
));
Carbon::setLocale(config('app.locale'));
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
Paginator::useBootstrap();
$today = Carbon::now();
// * Current time
$start_winter = Carbon::create($today->year, 12, 21, 0, 0, 0);
$start_spring = Carbon::create($today->year, 3, 20, 0, 0, 0);
$start_spring_nextyear = Carbon::create($today->year + 1, 3, 20, 0, 0, 0);
$start_summer = Carbon::create($today->year, 6, 21, 0, 0, 0);
$start_fall = Carbon::create($today->year, 9, 22, 0, 0, 0);
// * Default
$saison_css = "winter";
if ($today->between($start_winter, $start_spring_nextyear, true)) {
$saison_css = "winter";
}
if ($today->between($start_spring, $start_summer, true)) {
$saison_css = "spring";
}
if ($today->between($start_summer, $start_fall, true)) {
$saison_css = "summer";
}
if ($today->between($start_fall, $start_winter, true)) {
$saison_css = "fall";
}
View::share('saison_css', $saison_css);
}
}