src/Entity/Level.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LevelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Cycle;
  8. /**
  9. * @ORM\Entity(repositoryClass=LevelRepository::class)
  10. */
  11. class Level
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity=Cycle::class, inversedBy="levels")
  21. * @ORM\JoinColumn(nullable=false)
  22. */
  23. private $cycle;
  24. /**
  25. * @ORM\Column(type="string", length=255)
  26. */
  27. private $name;
  28. /**
  29. * @ORM\OneToMany(targetEntity=ClassRoom::class, mappedBy="level")
  30. */
  31. private $rooms;
  32. /**
  33. * @ORM\Column(type="integer", nullable=true)
  34. */
  35. private $amount;
  36. public function __construct()
  37. {
  38. $this->rooms = new ArrayCollection();
  39. }
  40. public function getId(): ?int
  41. {
  42. return $this->id;
  43. }
  44. public function getCycle(): ?Cycle
  45. {
  46. return $this->cycle;
  47. }
  48. public function setCycle(?Cycle $cycle): self
  49. {
  50. $this->cycle = $cycle;
  51. return $this;
  52. }
  53. public function getName(): ?string
  54. {
  55. return $this->name;
  56. }
  57. public function setName(string $name): self
  58. {
  59. $this->name = $name;
  60. return $this;
  61. }
  62. public function __toString()
  63. {
  64. $name = (is_null($this->getName())) ? "" : $this->getName();
  65. $cycle = (is_null($this->getCycle())) ? "" : $this->getCycle();
  66. return (string) ($cycle . "/" . $name);
  67. }
  68. /**
  69. * @return Collection|ClassRoom[]
  70. */
  71. public function getRooms(): Collection
  72. {
  73. return $this->rooms;
  74. }
  75. public function addRoom(ClassRoom $room): self
  76. {
  77. if (!$this->rooms->contains($room)) {
  78. $this->rooms[] = $room;
  79. $room->setLevel($this);
  80. }
  81. return $this;
  82. }
  83. public function removeRoom(ClassRoom $room): self
  84. {
  85. if ($this->rooms->removeElement($room)) {
  86. // set the owning side to null (unless already changed)
  87. if ($room->getLevel() === $this) {
  88. $room->setLevel(null);
  89. }
  90. }
  91. return $this;
  92. }
  93. public function getAmount(): ?int
  94. {
  95. return $this->amount;
  96. }
  97. public function setAmount(?int $amount): self
  98. {
  99. $this->amount = $amount;
  100. return $this;
  101. }
  102. }