<?phpnamespace App\Entity;use App\Repository\LevelRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use App\Entity\Cycle;/** * @ORM\Entity(repositoryClass=LevelRepository::class) */class Level{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity=Cycle::class, inversedBy="levels") * @ORM\JoinColumn(nullable=false) */ private $cycle; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\OneToMany(targetEntity=ClassRoom::class, mappedBy="level") */ private $rooms; /** * @ORM\Column(type="integer", nullable=true) */ private $amount; public function __construct() { $this->rooms = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getCycle(): ?Cycle { return $this->cycle; } public function setCycle(?Cycle $cycle): self { $this->cycle = $cycle; return $this; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function __toString() { $name = (is_null($this->getName())) ? "" : $this->getName(); $cycle = (is_null($this->getCycle())) ? "" : $this->getCycle(); return (string) ($cycle . "/" . $name); } /** * @return Collection|ClassRoom[] */ public function getRooms(): Collection { return $this->rooms; } public function addRoom(ClassRoom $room): self { if (!$this->rooms->contains($room)) { $this->rooms[] = $room; $room->setLevel($this); } return $this; } public function removeRoom(ClassRoom $room): self { if ($this->rooms->removeElement($room)) { // set the owning side to null (unless already changed) if ($room->getLevel() === $this) { $room->setLevel(null); } } return $this; } public function getAmount(): ?int { return $this->amount; } public function setAmount(?int $amount): self { $this->amount = $amount; return $this; }}