WIP: Implement availabilities
This commit is contained in:
+33
-5
@@ -83,9 +83,12 @@ class Teamer implements TimestampableEntityInterface
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $remarks = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Availability::class)]
|
||||
#[ORM\ManyToMany(targetEntity: Availability::class, inversedBy: 'teamers')]
|
||||
private Collection $availabilities;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Availability::class)]
|
||||
private Collection $customAvailabilities;
|
||||
|
||||
#[ORM\OneToOne(cascade: ['persist', 'remove'], fetch: 'EAGER')]
|
||||
#[Assert\NotNull(message: 'Bitte lade ein Foto von dir hoch', groups: ['profile', 'profile_preflight'])]
|
||||
private ?Upload $photo = null;
|
||||
@@ -136,6 +139,7 @@ class Teamer implements TimestampableEntityInterface
|
||||
$this->bookmarks = new ArrayCollection();
|
||||
$this->applications = new ArrayCollection();
|
||||
$this->dispositions = new ArrayCollection();
|
||||
$this->customAvailabilities = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function toPayload(): array
|
||||
@@ -375,7 +379,6 @@ class Teamer implements TimestampableEntityInterface
|
||||
{
|
||||
if (!$this->availabilities->contains($availability)) {
|
||||
$this->availabilities->add($availability);
|
||||
$availability->setOwner($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -383,10 +386,35 @@ class Teamer implements TimestampableEntityInterface
|
||||
|
||||
public function removeAvailability(Availability $availability): static
|
||||
{
|
||||
if ($this->availabilities->removeElement($availability)) {
|
||||
$this->availabilities->removeElement($availability);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Availability>
|
||||
*/
|
||||
public function getCustomAvailabilities(): Collection
|
||||
{
|
||||
return $this->customAvailabilities;
|
||||
}
|
||||
|
||||
public function addCustomAvailability(Availability $customAvailability): static
|
||||
{
|
||||
if (!$this->customAvailabilities->contains($customAvailability)) {
|
||||
$this->customAvailabilities->add($customAvailability);
|
||||
$customAvailability->setOwner($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeCustomAvailability(Availability $customAvailability): static
|
||||
{
|
||||
if ($this->customAvailabilities->removeElement($customAvailability)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($availability->getOwner() === $this) {
|
||||
$availability->setOwner(null);
|
||||
if ($customAvailability->getOwner() === $this) {
|
||||
$customAvailability->setOwner(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user