Fix create season issues, add number of teams to season response array
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Details
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Details
This commit is contained in:
parent
646e63a890
commit
b1a3b47aaf
|
|
@ -14,6 +14,7 @@ class SeasonDto
|
||||||
public array $teamDtoList;
|
public array $teamDtoList;
|
||||||
public array $facilityDtoList;
|
public array $facilityDtoList;
|
||||||
public int $leagueId;
|
public int $leagueId;
|
||||||
|
public int $numberOfTeams;
|
||||||
public int $seasonNumber;
|
public int $seasonNumber;
|
||||||
public int $gamesPerWeek;
|
public int $gamesPerWeek;
|
||||||
public string $leagueName;
|
public string $leagueName;
|
||||||
|
|
@ -28,9 +29,15 @@ class SeasonDto
|
||||||
|
|
||||||
public function createSeasonArray(): array
|
public function createSeasonArray(): array
|
||||||
{
|
{
|
||||||
|
$numberOfTeams = $this->numberOfTeams ?? 0;
|
||||||
|
if (!empty($this->teamDtoList))
|
||||||
|
{
|
||||||
|
$numberOfTeams = count($this->teamDtoList);
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
'id' => $this->id ?? null,
|
'id' => $this->id ?? null,
|
||||||
'seasonNumber' => $this->seasonNumber ?? null,
|
'seasonNumber' => $this->seasonNumber ?? null,
|
||||||
|
'numberOfTeams' => $numberOfTeams,
|
||||||
'gamesPerWeek' => $this->gamesPerWeek ?? null,
|
'gamesPerWeek' => $this->gamesPerWeek ?? null,
|
||||||
'dateStart' => !empty($this->dateStart) ? $this->dateStart->format('Y-m'): null,
|
'dateStart' => !empty($this->dateStart) ? $this->dateStart->format('Y-m'): null,
|
||||||
'leagueId' => $this->leagueId ?? null,
|
'leagueId' => $this->leagueId ?? null,
|
||||||
|
|
@ -76,6 +83,10 @@ class SeasonDto
|
||||||
{
|
{
|
||||||
$this->active = $dataList['active'];
|
$this->active = $dataList['active'];
|
||||||
}
|
}
|
||||||
|
if (isset($dataList['numberOfTeams']))
|
||||||
|
{
|
||||||
|
$this->numberOfTeams = $dataList['numberOfTeams'];
|
||||||
|
}
|
||||||
if (isset($dataList['teamList']))
|
if (isset($dataList['teamList']))
|
||||||
{
|
{
|
||||||
foreach ($dataList['teamList'] as $teamName)
|
foreach ($dataList['teamList'] as $teamName)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ class SeasonFactory
|
||||||
{
|
{
|
||||||
$seasonEntity->setPointsPerLoss($seasonDto->pointsPerLoss);
|
$seasonEntity->setPointsPerLoss($seasonDto->pointsPerLoss);
|
||||||
}
|
}
|
||||||
$seasonEntity->setActive(false);
|
|
||||||
return $seasonEntity;
|
return $seasonEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +52,7 @@ class HandleAddTeamList
|
||||||
$teamEntity = $this->teamFactory::createEntityFromDto($teamDto);
|
$teamEntity = $this->teamFactory::createEntityFromDto($teamDto);
|
||||||
$teamEntity->addSeason($seasonEntity);
|
$teamEntity->addSeason($seasonEntity);
|
||||||
$teamEntity->setLeagueId($leagueId);
|
$teamEntity->setLeagueId($leagueId);
|
||||||
|
$teamEntity->setActive(true);
|
||||||
$this->entityManager->persist($teamEntity);
|
$this->entityManager->persist($teamEntity);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
$teamDto->id = $teamEntity->getId();
|
$teamDto->id = $teamEntity->getId();
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class HandleCreateSeason
|
||||||
$numberOfTeams = $request->toArray()['numberOfTeams'];
|
$numberOfTeams = $request->toArray()['numberOfTeams'];
|
||||||
$seasonEntity = $this->seasonFactory::create($seasonDto);
|
$seasonEntity = $this->seasonFactory::create($seasonDto);
|
||||||
$seasonEntity->setLeague($leagueEntity);
|
$seasonEntity->setLeague($leagueEntity);
|
||||||
|
$seasonEntity->setActive(true);
|
||||||
if (!empty($numberOfTeams))
|
if (!empty($numberOfTeams))
|
||||||
{
|
{
|
||||||
$this->createTeams($numberOfTeams, $seasonEntity);
|
$this->createTeams($numberOfTeams, $seasonEntity);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue