ldc-jeusselin/app/Providers/AppServiceProvider.php
2021-03-23 12:19:28 +01:00

53 lines
1.4 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Carbon;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (!$this->app->environment("local")) {
URL::forceScheme("https");
}
$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_summer = Carbon::create($today->year, 6, 21, 0, 0, 0);
$start_fall = Carbon::create($today->year, 9, 22, 0, 0, 0);
if ($today->between($start_winter, $start_spring, 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);
}
}