src/Entity/SubjectGroup.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\SubjectGroupRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\HasLifecycleCallbacks]
  9. #[ORM\Entity(repositoryClassSubjectGroupRepository::class)]
  10. class SubjectGroup
  11. {
  12.     use Timestampable;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\OneToMany(mappedBy'subjectGroup'targetEntitySubject::class)]
  20.     private Collection $subjects;
  21.     #[ORM\ManyToOne(inversedBy'subjectGroups'cascade: ["persist"])]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?User $author null;
  24.     #[ORM\ManyToOne(inversedBy'subjectGroupsEdited'cascade: ["persist"])]
  25.     private ?User $editor null;
  26.     #[ORM\ManyToOne(inversedBy'subjectGroups'cascade: ["persist"])]
  27.     private ?School $school null;
  28.     #[ORM\ManyToOne(inversedBy'subjectGroups'cascade: ["persist"])]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?TheClass $classe null;
  31.     #[ORM\ManyToOne(inversedBy'subjectGroups')]
  32.     private ?SubjectGroupReference $reference null;
  33.     public function __toString():string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function __construct()
  38.     {
  39.         $this->subjects = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): static
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection<int, Subject>
  56.      */
  57.     public function getSubjects(): Collection
  58.     {
  59.         return $this->subjects;
  60.     }
  61.     public function addSubject(Subject $subject): static
  62.     {
  63.         if (!$this->subjects->contains($subject)) {
  64.             $this->subjects->add($subject);
  65.             $subject->setSubjectGroup($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeSubject(Subject $subject): static
  70.     {
  71.         if ($this->subjects->removeElement($subject)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($subject->getSubjectGroup() === $this) {
  74.                 $subject->setSubjectGroup(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79.     public function getAuthor(): ?User
  80.     {
  81.         return $this->author;
  82.     }
  83.     public function setAuthor(?User $author): static
  84.     {
  85.         $this->author $author;
  86.         return $this;
  87.     }
  88.     public function getEditor(): ?User
  89.     {
  90.         return $this->editor;
  91.     }
  92.     public function setEditor(?User $editor): static
  93.     {
  94.         $this->editor $editor;
  95.         return $this;
  96.     }
  97.     public function getSchool(): ?School
  98.     {
  99.         return $this->school;
  100.     }
  101.     public function setSchool(?School $school): static
  102.     {
  103.         $this->school $school;
  104.         return $this;
  105.     }
  106.     public function getClasse(): ?TheClass
  107.     {
  108.         return $this->classe;
  109.     }
  110.     public function setClasse(?TheClass $classe): static
  111.     {
  112.         $this->classe $classe;
  113.         return $this;
  114.     }
  115.     public function getReference(): ?SubjectGroupReference
  116.     {
  117.         return $this->reference;
  118.     }
  119.     public function setReference(?SubjectGroupReference $reference): static
  120.     {
  121.         $this->reference $reference;
  122.         return $this;
  123.     }
  124. }