src/Entity/Module.php line 13

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