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. public function getTeacher()
  52. {
  53. return $this->teacher;
  54. }
  55. public function getClassRoom(): ?ClassRoom
  56. {
  57. return $this->classRoom;
  58. }
  59. public function setClassRoom(?ClassRoom $classRoom): self
  60. {
  61. $this->classRoom = $classRoom;
  62. return $this;
  63. }
  64. public function setSchoolYear(SchoolYear $schoolYear)
  65. {
  66. $this->schoolYear = $schoolYear;
  67. return $this;
  68. }
  69. public function getSchoolYear()
  70. {
  71. return $this->schoolYear;
  72. }
  73. }