Files
myep-team/src/Entity/Training.php
T

83 lines
2.1 KiB
PHP

<?php
namespace App\Entity;
use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\SoftDeletableEntity;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\TrainingRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TrainingRepository::class)]
class Training implements BlameableEntityInterface, TimestampableEntityInterface, SoftDeletableEntityInterface
{
use BlameableEntity;
use TimestampableEntity;
use SoftDeletableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\OneToMany(mappedBy: 'training', targetEntity: TrainingAttendance::class)]
private Collection $trainingAttendances;
public function __construct()
{
$this->trainingAttendances = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, TrainingAttendance>
*/
public function getTrainingAttendances(): Collection
{
return $this->trainingAttendances;
}
public function addTrainingAttendance(TrainingAttendance $trainingAttendance): static
{
if (!$this->trainingAttendances->contains($trainingAttendance)) {
$this->trainingAttendances->add($trainingAttendance);
$trainingAttendance->setTraining($this);
}
return $this;
}
public function removeTrainingAttendance(TrainingAttendance $trainingAttendance): static
{
if ($this->trainingAttendances->removeElement($trainingAttendance)) {
// set the owning side to null (unless already changed)
if ($trainingAttendance->getTraining() === $this) {
$trainingAttendance->setTraining(null);
}
}
return $this;
}
}