WIP Impelement more stuff

This commit is contained in:
Björn Fromme
2023-10-04 15:10:16 +02:00
parent dec8feedf2
commit cc1ab396af
35 changed files with 928 additions and 177 deletions
+22 -8
View File
@@ -121,11 +121,11 @@ class Teamer implements TimestampableEntityInterface
#[ORM\Column]
private array $pickups = [];
#[ORM\Column(length: 255)]
#[ORM\Column(length: 255, nullable: true)]
#[Assert\NotBlank(message: 'Bitte gib deine Sprache(n) an', groups: ['profile', 'profile_preflight'])]
private ?string $language = null;
#[ORM\Column(length: 2)]
#[ORM\Column(length: 2, nullable: true)]
private ?string $size = null;
public function __construct()
@@ -143,6 +143,11 @@ class Teamer implements TimestampableEntityInterface
$this->customAvailabilities = new ArrayCollection();
}
public function __toString()
{
return $this->getFullName();
}
public function toPayload(): array
{
// Transform gender value
@@ -224,6 +229,15 @@ class Teamer implements TimestampableEntityInterface
return $this;
}
public function getFullName(bool $formal = false): string
{
if (true === $formal) {
return sprintf('%s, %s', $this->getLastName(), $this->getFirstName());
}
return sprintf('%s %s', $this->getFirstName(), $this->getLastName());
}
public function getGender(): ?string
{
return $this->gender;
@@ -494,15 +508,15 @@ class Teamer implements TimestampableEntityInterface
return $this;
}
public function hasTraining(Training $training): bool
public function getTrainingAttendance(Training $training): ?TrainingAttendance
{
foreach ($this->getTrainingAttendances() as $attendance) {
if ($attendance->getTraining() === $training) {
return true;
return $attendance;
}
}
return false;
return null;
}
/**
@@ -535,15 +549,15 @@ class Teamer implements TimestampableEntityInterface
return $this;
}
public function hasLicenseOfType(string $type): bool
public function getLicenseOfType(string $type): ?License
{
foreach ($this->getLicenses() as $license) {
if ($type === $license->getType()) {
return true;
return $license;
}
}
return false;
return null;
}
/**