<?phpnamespace App\Entity;use App\Repository\ModuleRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ModuleRepository::class) */class Module{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="string", length=255) */ private $code; /** * @ORM\ManyToOne(targetEntity=ClassRoom::class, inversedBy="modules") * @ORM\JoinColumn(nullable=false) */ private $room; /** * @ORM\OneToMany(targetEntity=Course::class, mappedBy="module") */ private $courses; public function __construct() { $this->courses = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getCode(): ?string { return $this->code; } public function setCode(string $code): self { $this->code = $code; return $this; } public function __toString() { $name = ( is_null($this->getName())) ? "" : $this->getName(); $code = ( is_null($this->getCode())) ? "" : $this->getCode(); return (string) ($code ); } public function getRoom(): ?ClassRoom { return $this->room; } public function setRoom(?ClassRoom $room): self { $this->room = $room; return $this; } /** * @return Collection|Course[] */ public function getCourses(): Collection { return $this->courses; } public function addCourse(Course $course): self { if (!$this->courses->contains($course)) { $this->courses[] = $course; $course->setModule($this); } return $this; } public function removeCourse(Course $course): self { if ($this->courses->removeElement($course)) { // set the owning side to null (unless already changed) if ($course->getModule() === $this) { $course->setModule(null); } } return $this; }}