fix season
This commit is contained in:
1 parent
d220e340e2
commit
7e30e93f90
5 files changed
+56
-48
No files matched your search
@@ -2,24 +2,25 @@
|
||||
|
||||
namespace App\Filament\Pages\Selections\Helper;
|
||||
|
||||
use App\Models\SofaScoreCategory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class GetSeason
|
||||
{
|
||||
public static function load(array $season, int|null $sofascore_category_id)
|
||||
public static function load(array|null $season, string|null $seasonmode)
|
||||
{
|
||||
if (!is_array($season) || !count($season)) {
|
||||
if ($sofascore_category_id) {
|
||||
$season_mode = SofaScoreCategory::where('id', $sofascore_category_id)->value('season_mode');
|
||||
if ($season_mode == 'halfyear') {
|
||||
if ((int) date('m') > 7)
|
||||
$season[] = date('y') . '/' . date('y', strtotime('+1 year'));
|
||||
else
|
||||
$season[] = date('y', strtotime('-1 year')) . '/' . date('y');
|
||||
}
|
||||
else {
|
||||
$season[] = date('Y');
|
||||
}
|
||||
if (!\is_array($season) || !\count($season)) {
|
||||
|
||||
$date = Carbon::now();
|
||||
|
||||
$season = [];
|
||||
if ($seasonmode == '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[$date->year] = $date->year;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user