src/Entity/CoverageArea.php line 13

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