Change response format of league object
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good Details

This commit is contained in:
Daniel Guzman 2024-06-02 11:56:15 +02:00
parent d36cee95e6
commit a958119534
3 changed files with 17 additions and 2 deletions

View File

@ -38,6 +38,7 @@ class LeagueDto
return [
'id' => $this->id ?? null,
'name' => $this->name ?? null,
'city' => $this->city ?? null,
'logo' => $this->logo ?? null,
'description' => $this->description ?? null,
'pointsPerWin' => $this->pointsPerWin ?? null,
@ -53,6 +54,20 @@ class LeagueDto
];
}
public function getAllLeaguesArray(): array
{
$seasonCount = !empty($this->seasonDtoList) ? count($this->seasonDtoList) : 0;
return [
'id' => $this->id ?? '',
'name' => $this->name ?? '',
'city' => $this->city ?? '',
'logo' => $this->logo ?? '',
'description' => $this->description ?? '',
'isPublic' => $this->isPublic ?? '',
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : '',
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))

View File

@ -42,8 +42,8 @@ class HandleCreateLeague
$leagueDto = new LeagueDto();
$leagueDto->fillFromArray($request->toArray());
$leagueDto->validate();
$leagueDto->active = true;
$leagueEntity = $this->leagueFactory::create($leagueDto);
$leagueEntity->setActive(true);
$this->entityManager->persist($leagueEntity);
$this->entityManager->flush();

View File

@ -34,7 +34,7 @@ class HandleGetAllLeagues
{
$leagueDto = new LeagueDto();
$leagueDto->fillFromObject($leagueObj);
$leagueArray[] = $leagueDto->toArray();
$leagueArray[] = $leagueDto->getAllLeaguesArray();
}
}
return new JsonResponse(