Fix create season issues, add number of teams to season response array
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good Details

This commit is contained in:
Daniel Guzman 2024-07-24 23:43:57 +02:00
parent 646e63a890
commit b1a3b47aaf
4 changed files with 13 additions and 2 deletions

View File

@ -14,6 +14,7 @@ class SeasonDto
public array $teamDtoList;
public array $facilityDtoList;
public int $leagueId;
public int $numberOfTeams;
public int $seasonNumber;
public int $gamesPerWeek;
public string $leagueName;
@ -28,9 +29,15 @@ class SeasonDto
public function createSeasonArray(): array
{
$numberOfTeams = $this->numberOfTeams ?? 0;
if (!empty($this->teamDtoList))
{
$numberOfTeams = count($this->teamDtoList);
}
return [
'id' => $this->id ?? null,
'seasonNumber' => $this->seasonNumber ?? null,
'numberOfTeams' => $numberOfTeams,
'gamesPerWeek' => $this->gamesPerWeek ?? null,
'dateStart' => !empty($this->dateStart) ? $this->dateStart->format('Y-m'): null,
'leagueId' => $this->leagueId ?? null,
@ -76,6 +83,10 @@ class SeasonDto
{
$this->active = $dataList['active'];
}
if (isset($dataList['numberOfTeams']))
{
$this->numberOfTeams = $dataList['numberOfTeams'];
}
if (isset($dataList['teamList']))
{
foreach ($dataList['teamList'] as $teamName)

View File

@ -28,7 +28,6 @@ class SeasonFactory
{
$seasonEntity->setPointsPerLoss($seasonDto->pointsPerLoss);
}
$seasonEntity->setActive(false);
return $seasonEntity;
}
}

View File

@ -52,6 +52,7 @@ class HandleAddTeamList
$teamEntity = $this->teamFactory::createEntityFromDto($teamDto);
$teamEntity->addSeason($seasonEntity);
$teamEntity->setLeagueId($leagueId);
$teamEntity->setActive(true);
$this->entityManager->persist($teamEntity);
$this->entityManager->flush();
$teamDto->id = $teamEntity->getId();

View File

@ -53,7 +53,7 @@ class HandleCreateSeason
$numberOfTeams = $request->toArray()['numberOfTeams'];
$seasonEntity = $this->seasonFactory::create($seasonDto);
$seasonEntity->setLeague($leagueEntity);
$seasonEntity->setActive(true);
if (!empty($numberOfTeams))
{
$this->createTeams($numberOfTeams, $seasonEntity);