Get All Leagues, Get All Teams, Add Teams
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good Details

This commit is contained in:
Daniel Guzman 2024-07-21 00:09:12 +02:00
parent 4cdc3c38ef
commit 7bfb300a59
2 changed files with 27 additions and 8 deletions

View File

@ -40,14 +40,25 @@ class HandleAddTeam
'Temporada con ID: '. $seasonId .' no ha sido encontrada.'
);
}
$teamDto = new TeamDto();
$teamDto->fillFromArray($request->toArray());
if (!empty($request->toArray()))
{
$teamDtoList = [];
foreach ($request->toArray() as $teamItem)
{
$teamDto = $this->teamFactory::createDtoFromArray($teamItem);
$teamDto->validate();
$teamEntity = $this->teamFactory::create($teamDto);
$teamEntity = $this->teamFactory::createEntityFromDto($teamDto);
$teamEntity->addSeason($seasonEntity);
$teamEntity->setLeagueId($leagueId);
$this->entityManager->persist($teamEntity);
$this->entityManager->flush();
$teamDto->id = $teamEntity->getId();
$teamDtoList[] = $teamDto->toArray();
}
}
return new JsonResponse(
data: [

View File

@ -0,0 +1,8 @@
<?php
namespace DMD\LaLigaApi\Service\Season\getAllTeams;
class HandleGetAllTeams
{
}