WIP: Implement model
This commit is contained in:
1 parent
35ca61d21b
commit
f8c9ff82a5
35 files changed
+2935
No files matched your search
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
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
|
||||
{
|
||||
use BlameableEntity;
|
||||
use TimestampableEntity;
|
||||
|
||||
#[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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user