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\Column(nullabletrue)]
  20.     private ?int $position null;
  21.     #[ORM\OneToMany(mappedBy'subjectGroup'targetEntitySubject::class)]
  22.     private Collection $subjects;
  23.     #[ORM\ManyToOne(inversedBy'subjectGroups'cascade: ["persist"])]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private ?User $author null;
  26.     #[ORM\ManyToOne(inversedBy'subjectGroupsEdited'cascade: ["persist"])]
  27.     private ?User $editor null;
  28.     #[ORM\ManyToOne(inversedBy'subjectGroups'cascade: ["persist"])]
  29.     private ?School $school null;
  30.     #[ORM\ManyToOne(inversedBy'subjectGroups'cascade: ["persist"])]
  31.     #[ORM\JoinColumn(nullablefalse)]
  32.     private ?TheClass $classe null;
  33.     #[ORM\ManyToOne(inversedBy'subjectGroups')]
  34.     private ?SubjectGroupReference $reference null;
  35.     public function __toString():string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function __construct()
  40.     {
  41.         $this->subjects = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): static
  52.     {
  53.         $this->name $name;
  54.         return $this;
  55.     }
  56.     public function getPosition(): ?int
  57.     {
  58.         return $this->position;
  59.     }
  60.     public function setPosition(?int $position): static
  61.     {
  62.         $this->position $position;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, Subject>
  67.      */
  68.     public function getSubjects(): Collection
  69.     {
  70.         return $this->subjects;
  71.     }
  72.     public function addSubject(Subject $subject): static
  73.     {
  74.         if (!$this->subjects->contains($subject)) {
  75.             $this->subjects->add($subject);
  76.             $subject->setSubjectGroup($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeSubject(Subject $subject): static
  81.     {
  82.         if ($this->subjects->removeElement($subject)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($subject->getSubjectGroup() === $this) {
  85.                 $subject->setSubjectGroup(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     public function getAuthor(): ?User
  91.     {
  92.         return $this->author;
  93.     }
  94.     public function setAuthor(?User $author): static
  95.     {
  96.         $this->author $author;
  97.         return $this;
  98.     }
  99.     public function getEditor(): ?User
  100.     {
  101.         return $this->editor;
  102.     }
  103.     public function setEditor(?User $editor): static
  104.     {
  105.         $this->editor $editor;
  106.         return $this;
  107.     }
  108.     public function getSchool(): ?School
  109.     {
  110.         return $this->school;
  111.     }
  112.     public function setSchool(?School $school): static
  113.     {
  114.         $this->school $school;
  115.         return $this;
  116.     }
  117.     public function getClasse(): ?TheClass
  118.     {
  119.         return $this->classe;
  120.     }
  121.     public function setClasse(?TheClass $classe): static
  122.     {
  123.         $this->classe $classe;
  124.         return $this;
  125.     }
  126.     public function getReference(): ?SubjectGroupReference
  127.     {
  128.         return $this->reference;
  129.     }
  130.     public function setReference(?SubjectGroupReference $reference): static
  131.     {
  132.         $this->reference $reference;
  133.         return $this;
  134.     }
  135. }