Files
nuhodds_fi4/app/Filament/Pages/Selections/Helper/GetSeason.php
T
2026-10-04 15:25:03 +02:00

49 lines
1.2 KiB
PHP

<?php
namespace App\Filament\Pages\Selections\Helper;
use Illuminate\Support\Carbon;
class GetSeason
{
public static function load(?array $season, ?string $seasonmode)
{
if (! \is_array($season) || ! \count($season)) {
$date = Carbon::now();
$season = [];
if ($seasonmode == 'halfyear') {
if ((int) date('m') > 7) {
$season[] = (string) $date->format('y').'/'.$date->format('y') + 1;
} else {
$season[] = (string) $date->format('y') - 1 .'/'.$date->format('y');
}
} else {
$season[] = (string) $date->year;
}
}
return $season;
}
public static function active(?string $seasonmode)
{
$date = Carbon::now();
$active_season = '';
if ($seasonmode == 'halfyear') {
if ((int) date('m') > 7) {
$active_season = (string) $date->format('y').'/'.$date->format('y') + 1;
} else {
$active_season = (string) $date->format('y') - 1 .'/'.$date->format('y');
}
} else {
$active_season = (string) $date->year;
}
return $active_season;
}
}