WIP Impelement more stuff
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\PeriodRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PeriodRepository::class)]
|
||||
class Period implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
{
|
||||
use BlameableEntity;
|
||||
use TimestampableEntity;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $dateFrom = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $dateTo = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateFrom;
|
||||
}
|
||||
|
||||
public function setDateFrom(\DateTimeImmutable $dateFrom): static
|
||||
{
|
||||
$this->dateFrom = $dateFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateTo(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateTo;
|
||||
}
|
||||
|
||||
public function setDateTo(\DateTimeImmutable $dateTo): static
|
||||
{
|
||||
$this->dateTo = $dateTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+22
-8
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user