Change response format of league object
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
d36cee95e6
commit
a958119534
|
|
@ -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']))
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class HandleGetAllLeagues
|
|||
{
|
||||
$leagueDto = new LeagueDto();
|
||||
$leagueDto->fillFromObject($leagueObj);
|
||||
$leagueArray[] = $leagueDto->toArray();
|
||||
$leagueArray[] = $leagueDto->getAllLeaguesArray();
|
||||
}
|
||||
}
|
||||
return new JsonResponse(
|
||||
|
|
|
|||
Loading…
Reference in New Issue