src/Entity/MainTeacher.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\User;
  4. use App\Entity\ClassRoom;
  5. use App\Entity\SchoolYear;
  6. use App\Repository\MainTeacherRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Entity\Traits\TimeStampable;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass=MainTeacherRepository::class)
  12.  * @UniqueEntity(fields={"classRoom", "schoolYear"}, message= "There is already a MainTeacher in this class at this year")
  13.  */
  14. class MainTeacher
  15. {
  16.     use TimeStampable;
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private ?int $id null;
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="mainTeachers")
  25.      * @ORM\JoinColumn(nullable=true)
  26.      */
  27.     private $teacher;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=ClassRoom::class, inversedBy="mainTeachers")
  30.      * @ORM\JoinColumn(nullable=false)
  31.      */
  32.     private $classRoom;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=SchoolYear::class, inversedBy="subscriptions")
  35.      * @ORM\JoinColumn(nullable=false)
  36.      */
  37.     private $schoolYear;
  38.     public function __construct()
  39.     {
  40.         $this->updateTimestamp();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function setTeacher(User $teacher)
  47.     {
  48.         $this->teacher $teacher;
  49.         return $this;
  50.     }
  51.    
  52.     public function getTeacher()
  53.     {
  54.         return $this->teacher;
  55.     }
  56.     public function getClassRoom(): ?ClassRoom
  57.     {
  58.         return $this->classRoom;
  59.     }
  60.     public function setClassRoom(?ClassRoom $classRoom): self
  61.     {
  62.         $this->classRoom $classRoom;
  63.         return $this;
  64.     }
  65.     public function setSchoolYear(SchoolYear $schoolYear)
  66.     {
  67.         $this->schoolYear $schoolYear;
  68.         return $this;
  69.     }
  70.     
  71.     public function getSchoolYear()
  72.     {
  73.         return $this->schoolYear;
  74.     }
  75. }