agregar pabellon a tabla de equipos, mejorar respuesta de registro de usuario, normalizar mensajes de error

This commit is contained in:
Daniel Guzman
2024-05-23 00:22:06 +02:00
parent 557b586b76
commit 82282ebbca
387 changed files with 889 additions and 606 deletions
+31 -8
View File
@@ -3,6 +3,7 @@
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Facility;
use DMD\LaLigaApi\Exception\ValidationException;
use phpDocumentor\Reflection\Types\Integer;
class FacilityDto
@@ -10,10 +11,12 @@ class FacilityDto
public int $id;
public string $name;
public string $address;
public array $availableHourList;
public bool $active;
public array $gameDtoList;
public array $seasonDtoList;
public \DateTime $createdAt;
public \DateTimeImmutable $createdAt;
public array $validationErrors;
public function toArray(): array
{
@@ -29,7 +32,7 @@ class FacilityDto
'id' => $this->id ?? '',
'name' => $this->name ?? '',
'address' => $this->address ?? '',
'seasonList' => $seasonList,
'availableHours' => $this->availableHourList ?? [],
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : ''
];
}
@@ -52,6 +55,10 @@ class FacilityDto
{
$this->active = $dataList['active'];
}
if (isset($dataList['availableHours']))
{
$this->availableHourList = $dataList['availableHours'];
}
if (!empty($dataList['seasonList']))
{
foreach ($dataList['seasonList'] as $seasonItem)
@@ -63,7 +70,7 @@ class FacilityDto
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $dataList['createdAt'], new \DateTimeZone('Europe/Madrid'));
$this->createdAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['createdAt'], new \DateTimeZone('Europe/Madrid'));
}
}
@@ -81,17 +88,33 @@ class FacilityDto
{
$this->address = $facilityEntity->getAddress();
}
if ($facilityEntity->getAvailableHours() !== null)
{
$this->availableHourList = $facilityEntity->getAvailableHours();
}
if ($facilityEntity->getCreatedAt() !== null)
{
$this->createdAt = new \DateTime($facilityEntity->getCreatedAt(), new \DateTimeZone('Europe/Madrid'));
$this->createdAt =$facilityEntity->getCreatedAt();
}
}
public function validate(): void
{
// if (empty($this->name))
// {
// $this->validationErrors[] = 'El nombre del equipo no puede estar vacío.';
// }
if (empty($this->name))
{
$this->validationErrors[] = 'El nombre del pabellón no puede estar vacío.';
}
if (empty($this->address))
{
$this->validationErrors[] = 'La dirección del pabellón no puede estar vacío.';
}
if (empty($this->availableHourList))
{
$this->validationErrors[] = 'Las horas disponibles del pabellón no pueden estar vacías.';
}
if (!empty($this->validationErrors))
{
throw new ValidationException($this->validationErrors);
}
}
}
+13
View File
@@ -42,6 +42,19 @@ class UserDto
];
}
public function toRegisterArray(): array
{
return [
'id' => $this->id ?? null,
'email' => $this->email ?? null,
'firstName' => $this->firstName ?? null,
'lastName' => $this->lastName ?? null,
'phone' => $this->phone,
'profilePicture' => $this->profilePicture ?? null,
'birthday' => $this->birthday->format('Y-m-d'),
];
}
public function fillFromObject(User $userObj): void
{
if ($userObj->getId() !== null)