src/Entity/Domain.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\User;
  4. use App\Entity\Course;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\DomainRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. /**
  10.  * @ORM\Entity(repositoryClass=DomainRepository::class)
  11.  */
  12. class Domain
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\OneToMany(targetEntity=Course::class, mappedBy="domain")
  26.      */
  27.     private $courses;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=User::class,inversedBy="headOfDepartementOf")
  30.      * @ORM\JoinColumn(name="headOfDepartmentId", referencedColumnName="id", nullable=true)
  31.      */
  32.     private $headOfDepartment;
  33.      /**
  34.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="domain")
  35.      */
  36.     private $teachers;
  37.     
  38.     public function __construct()
  39.     {
  40.         $this->courses = new ArrayCollection();
  41.         $this->teachers = new ArrayCollection();
  42.       
  43.       
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): self
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     public function __toString() {
  59.         $name = ( is_null($this->getName())) ? "" $this->getName();
  60.          
  61.         return (string) ($name );
  62.     }
  63.     /**
  64.      * @return Collection|Course[]
  65.      */
  66.     public function getCourses(): Collection
  67.     {
  68.         return $this->courses;
  69.     }
  70.     public function addCourse(Course $course): self
  71.     {
  72.         if (!$this->courses->contains($course)) {
  73.             $this->courses[] = $course;
  74.             $course->setDomain($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeCourse(Course $course): self
  79.     {
  80.         if ($this->courses->removeElement($course)) {
  81.             // set the owning side to null (unless already changed)
  82.             if ($course->getDomain() === $this) {
  83.                 $course->setDomain(null);
  84.             }
  85.         }
  86.         return $this;
  87.     }
  88.     /**
  89.      * @return Collection|User[]
  90.      */
  91.     public function getTeachers(): Collection
  92.     {
  93.         return $this->teachers;
  94.     }
  95.     public function addTeacher(User $teacher): self
  96.     {
  97.         if (!$this->teachers->contains($teacher)) {
  98.             $this->teachers[] = $teacher;
  99.             $teacher->setDomain($this);
  100.         }
  101.         return $this;
  102.     }
  103.     public function removeTeacher(User $teacher): self
  104.     {
  105.         if ($this->teachers->removeElement($teacher)) {
  106.             // set the owning side to null (unless already changed)
  107.             if ($teacher->getDomain() === $this) {
  108.                 $teacher->setDomain(null);
  109.             }
  110.         }
  111.         return $this;
  112.     }
  113.     public function getHeadOfDepartment(): ?User
  114.     {
  115.         return $this->headOfDepartment;
  116.     }
  117.     public function setHeadOfDepartment(?User $headOfDepartment): self
  118.     {
  119.         $this->headOfDepartment $headOfDepartment;
  120.         return $this;
  121.     }
  122. }