<?phpnamespace App\Entity;use App\Entity\User;use App\Entity\Course;use Doctrine\ORM\Mapping as ORM;use App\Repository\DomainRepository;use Doctrine\Common\Collections\Collection;use Doctrine\Common\Collections\ArrayCollection;/** * @ORM\Entity(repositoryClass=DomainRepository::class) */class Domain{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\OneToMany(targetEntity=Course::class, mappedBy="domain") */ private $courses; /** * @ORM\ManyToOne(targetEntity=User::class,inversedBy="headOfDepartementOf") * @ORM\JoinColumn(name="headOfDepartmentId", referencedColumnName="id", nullable=true) */ private $headOfDepartment; /** * @ORM\OneToMany(targetEntity=User::class, mappedBy="domain") */ private $teachers; public function __construct() { $this->courses = new ArrayCollection(); $this->teachers = 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 __toString() { $name = ( is_null($this->getName())) ? "" : $this->getName(); return (string) ($name ); } /** * @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->setDomain($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->getDomain() === $this) { $course->setDomain(null); } } return $this; } /** * @return Collection|User[] */ public function getTeachers(): Collection { return $this->teachers; } public function addTeacher(User $teacher): self { if (!$this->teachers->contains($teacher)) { $this->teachers[] = $teacher; $teacher->setDomain($this); } return $this; } public function removeTeacher(User $teacher): self { if ($this->teachers->removeElement($teacher)) { // set the owning side to null (unless already changed) if ($teacher->getDomain() === $this) { $teacher->setDomain(null); } } return $this; } public function getHeadOfDepartment(): ?User { return $this->headOfDepartment; } public function setHeadOfDepartment(?User $headOfDepartment): self { $this->headOfDepartment = $headOfDepartment; return $this; }}