49 lines
1.2 KiB
PHP
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 $season_mode)
|
|
{
|
|
if (! \is_array($season) || ! \count($season)) {
|
|
|
|
$date = Carbon::now();
|
|
|
|
$season = [];
|
|
if ($season_mode == '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 $season_mode)
|
|
{
|
|
|
|
$date = Carbon::now();
|
|
|
|
$active_season = '';
|
|
if ($season_mode == '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;
|
|
}
|
|
}
|