Update create season response
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good

This commit is contained in:
Daniel Guzman
2024-06-02 23:52:57 +02:00
parent fbb57e80de
commit fa24f75fea
9 changed files with 51 additions and 33 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ class GameDto
'awayTeam' => $this->awayTeamDto->toArray() ?? [],
'plannedDate' => !empty($this->plannedDate) ? $this->plannedDate->format('Y-m-d H:i:s') : null,
'gameDateTime' => !empty($this->gameDateTime) ? $this->gameDateTime->format('Y-m-d H:i:s') : null,
'season' => $this->seasonDto->toArray() ?? [],
'season' => $this->seasonDto->createSeasonArray() ?? [],
'notes' => $this->notes ?? null,
'facility' => $this->facilityDto->toArray() ?? [],
'pointsHome' => $this->pointsHome ?? 0,
+9 -20
View File
@@ -12,6 +12,8 @@ class SeasonDto
public array $teamDtoList;
public array $facilityDtoList;
public int $leagueId;
public int $seasonNumber;
public string $leagueName;
public int $pointsPerWin;
public int $pointsPerLoss;
public int $pointsPerDraw;
@@ -20,30 +22,17 @@ class SeasonDto
public bool $active;
public array $validationErrors;
public function toArray(): array
public function createSeasonArray(): array
{
$teamList = [];
$facilityList = [];
if (!empty($this->teamDtoList))
{
foreach ($this->teamDtoList as $teamDto)
{
$teamList[] = $teamDto->toArray();
}
}
if (!empty($this->facilityDtoList))
{
foreach ($this->facilityDtoList as $facilityDto)
{
$facilityList[] = $facilityDto->toArray();
}
}
return [
'id' => $this->id ?? null,
'seasonNumber' => $this->seasonNumber ?? null,
'dateStart' => !empty($this->dateStart) ? $this->dateStart->format('Y-m'): null,
'leagueId' => $this->leagueId ?? null,
'teamList' => $teamList,
'facilityList' => $facilityList,
'leagueName' => $this->leagueName ?? null,
'pointsPerWin' => $this->pointsPerWin ?? null,
'pointsPerDraw' => $this->pointsPerDraw ?? null,
'pointsPerLoss' => $this->pointsPerLoss ?? null,
'active' => $this->active ?? null
];
}
@@ -56,7 +45,7 @@ class SeasonDto
}
if (!empty($dataList['dateStart']))
{
$dateStart = \DateTime::createFromFormat('Y-m' ,$dataList['dateStart']);
$dateStart = \DateTime::createFromFormat('Y-m', $dataList['dateStart']);
if ($dateStart)
{
$this->dateStart = $dateStart;