WIP: Implement availabilities
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Entity;
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\AvailabilityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@@ -25,9 +27,17 @@ class Availability implements BlameableEntityInterface, TimestampableEntityInter
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $dateTo = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'availabilities')]
|
||||
#[ORM\ManyToOne(inversedBy: 'customAvailabilities')]
|
||||
private ?Teamer $owner = null;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Teamer::class, mappedBy: 'availabilities')]
|
||||
private Collection $teamers;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->teamers = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -68,4 +78,31 @@ class Availability implements BlameableEntityInterface, TimestampableEntityInter
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Teamer>
|
||||
*/
|
||||
public function getTeamers(): Collection
|
||||
{
|
||||
return $this->teamers;
|
||||
}
|
||||
|
||||
public function addTeamer(Teamer $teamer): static
|
||||
{
|
||||
if (!$this->teamers->contains($teamer)) {
|
||||
$this->teamers->add($teamer);
|
||||
$teamer->addAvailability($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeTeamer(Teamer $teamer): static
|
||||
{
|
||||
if ($this->teamers->removeElement($teamer)) {
|
||||
$teamer->removeAvailability($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user