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.     public function __toString():string
  32.     {
  33.         return $this->name;
  34.     }
  35.     public function __construct()
  36.     {
  37.         $this->subjects = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): static
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection<int, Subject>
  54.      */
  55.     public function getSubjects(): Collection
  56.     {
  57.         return $this->subjects;
  58.     }
  59.     public function addSubject(Subject $subject): static
  60.     {
  61.         if (!$this->subjects->contains($subject)) {
  62.             $this->subjects->add($subject);
  63.             $subject->setSubjectGroup($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeSubject(Subject $subject): static
  68.     {
  69.         if ($this->subjects->removeElement($subject)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($subject->getSubjectGroup() === $this) {
  72.                 $subject->setSubjectGroup(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     public function getAuthor(): ?User
  78.     {
  79.         return $this->author;
  80.     }
  81.     public function setAuthor(?User $author): static
  82.     {
  83.         $this->author $author;
  84.         return $this;
  85.     }
  86.     public function getEditor(): ?User
  87.     {
  88.         return $this->editor;
  89.     }
  90.     public function setEditor(?User $editor): static
  91.     {
  92.         $this->editor $editor;
  93.         return $this;
  94.     }
  95.     public function getSchool(): ?School
  96.     {
  97.         return $this->school;
  98.     }
  99.     public function setSchool(?School $school): static
  100.     {
  101.         $this->school $school;
  102.         return $this;
  103.     }
  104.     public function getClasse(): ?TheClass
  105.     {
  106.         return $this->classe;
  107.     }
  108.     public function setClasse(?TheClass $classe): static
  109.     {
  110.         $this->classe $classe;
  111.         return $this;
  112.     }
  113. }