src/Entity/UserYear.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserYearRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Traits\Timestampable;
  8. use JMS\Serializer\Annotation\Groups;
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Entity(repositoryClassUserYearRepository::class)]
  11. class UserYear
  12. {
  13.     use Timestampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\ManyToOne(inversedBy'userYears')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     #[Groups(['chatView',  'chatAllList''singleMessage','getAppUsers'])]
  21.     private ?User $user null;
  22.     #[ORM\ManyToOne(inversedBy'userYears')]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private ?SchoolYear $year null;
  25.     #[ORM\Column(length255)]
  26.     private ?string $userType null;
  27.     #[ORM\ManyToOne(inversedBy'userYears')]
  28.     #[Groups(['getAppUsers'])]
  29.     private ?School $school null;
  30.     #[ORM\OneToMany(mappedBy'principalProf'targetEntityTheClass::class)]
  31.     private Collection $principalClasses;
  32.     public function __construct()
  33.     {
  34.         $this->messages = new ArrayCollection();
  35.         $this->principalClasses = new ArrayCollection();
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getUser(): ?User
  42.     {
  43.         return $this->user;
  44.     }
  45.     public function setUser(?User $user): static
  46.     {
  47.         $this->user $user;
  48.         return $this;
  49.     }
  50.     public function getYear(): ?SchoolYear
  51.     {
  52.         return $this->year;
  53.     }
  54.     public function setYear(?SchoolYear $year): static
  55.     {
  56.         $this->year $year;
  57.         return $this;
  58.     }
  59.     public function getUserType(): ?string
  60.     {
  61.         return $this->userType;
  62.     }
  63.     public function setUserType(string $userType): static
  64.     {
  65.         $this->userType $userType;
  66.         return $this;
  67.     }
  68.     public function getSchool(): ?School
  69.     {
  70.         return $this->school;
  71.     }
  72.     public function setSchool(?School $school): static
  73.     {
  74.         $this->school $school;
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, TheClass>
  79.      */
  80.     public function getPrincipalClasses(): Collection
  81.     {
  82.         return $this->principalClasses;
  83.     }
  84.     public function addPrincipalClass(TheClass $principalClass): static
  85.     {
  86.         if (!$this->principalClasses->contains($principalClass)) {
  87.             $this->principalClasses->add($principalClass);
  88.             $principalClass->setPrincipalProf($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removePrincipalClass(TheClass $principalClass): static
  93.     {
  94.         if ($this->principalClasses->removeElement($principalClass)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($principalClass->getPrincipalProf() === $this) {
  97.                 $principalClass->setPrincipalProf(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102. }