src/Entity/CoverageArea.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CoverageAreaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=CoverageAreaRepository::class)
  9. */
  10. class CoverageArea
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\ManyToMany(targetEntity=Department::class, inversedBy="coverageAreas", cascade={"persist", "remove"})
  20. */
  21. private $departments;
  22. /**
  23. * @ORM\OneToOne(targetEntity=User::class, mappedBy="coverageArea", cascade={"persist", "remove"})
  24. */
  25. private $user;
  26. public function __construct()
  27. {
  28. $this->departments = new ArrayCollection();
  29. }
  30. public function getId(): ?int
  31. {
  32. return $this->id;
  33. }
  34. /**
  35. * @return Collection|Department[]
  36. */
  37. public function getDepartments(): Collection
  38. {
  39. return $this->departments;
  40. }
  41. public function addDepartment( Department $department ): self
  42. {
  43. if ( !$this->departments->contains( $department ) ) {
  44. $this->departments[] = $department;
  45. }
  46. return $this;
  47. }
  48. public function removeDepartment( Department $department ): self
  49. {
  50. $this->departments->removeElement( $department );
  51. return $this;
  52. }
  53. public function getUser(): ?User
  54. {
  55. return $this->user;
  56. }
  57. public function setUser(User $user): self
  58. {
  59. $this->user = $user;
  60. return $this;
  61. }
  62. }