34 lines
867 B
PHP
34 lines
867 B
PHP
<?php
|
|
|
|
namespace App\Filament\Pages\Selections;
|
|
|
|
use Carbon\CarbonPeriod;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class LoadSeasons
|
|
{
|
|
public static function load(string $season_mode)
|
|
{
|
|
if (! $season_mode) {
|
|
return [];
|
|
}
|
|
|
|
$season = [];
|
|
$period = CarbonPeriod::create(Carbon::now()->year(2024), '1 year', Carbon::now());
|
|
foreach ($period as $date) {
|
|
if ($season_mode == 'halfyear') {
|
|
if ((int) date('m') > 7) {
|
|
$tmp = $date->format('y').'/'.$date->format('y') + 1;
|
|
} else {
|
|
$tmp = $date->format('y') - 1 .'/'.$date->format('y');
|
|
}
|
|
$season[$tmp] = $tmp;
|
|
} else {
|
|
$season[(string) $date->year] = (string) $date->year;
|
|
}
|
|
}
|
|
|
|
return $season;
|
|
}
|
|
}
|