src/Entity/Department.php line 13

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\DepartmentRepository;
  4.     use Doctrine\Common\Collections\ArrayCollection;
  5.     use Doctrine\Common\Collections\Collection;
  6.     use Doctrine\ORM\Mapping as ORM;
  7.     /**
  8.      * @ORM\Entity(repositoryClass=DepartmentRepository::class)
  9.      */
  10.     class Department
  11.     {
  12.         /**
  13.          * @ORM\Id
  14.          * @ORM\GeneratedValue
  15.          * @ORM\Column(type="integer")
  16.          */
  17.         private $id;
  18.         /**
  19.          * @ORM\Column(type="string", length=3)
  20.          */
  21.         private $code;
  22.         /**
  23.          * @ORM\Column(type="string", length=255)
  24.          */
  25.         private $name;
  26.         /**
  27.          * @ORM\Column(type="string", length=255)
  28.          */
  29.         private $slug;
  30.         /**
  31.          * @ORM\ManyToMany(targetEntity=CoverageArea::class, mappedBy="departments")
  32.          */
  33.         private $coverageAreas;
  34.         public function __construct()
  35.         {
  36.             $this->coverageAreas = new ArrayCollection();
  37.         }
  38.         public function __toString()
  39.         {
  40.             return $this->name ' (' $this->code ')';
  41.         }
  42.         public function getId(): ?int
  43.         {
  44.             return $this->id;
  45.         }
  46.         public function getCode(): ?string
  47.         {
  48.             return $this->code;
  49.         }
  50.         public function setCodestring $code ): self
  51.         {
  52.             $this->code $code;
  53.             return $this;
  54.         }
  55.         public function getName(): ?string
  56.         {
  57.             return $this->name;
  58.         }
  59.         public function setNamestring $name ): self
  60.         {
  61.             $this->name $name;
  62.             return $this;
  63.         }
  64.         public function getSlug(): ?string
  65.         {
  66.             return $this->slug;
  67.         }
  68.         public function setSlugstring $slug ): self
  69.         {
  70.             $this->slug $slug;
  71.             return $this;
  72.         }
  73.         /**
  74.          * @return Collection|CoverageArea[]
  75.          */
  76.         public function getCoverageAreas(): Collection
  77.         {
  78.             return $this->coverageAreas;
  79.         }
  80.         public function addCoverageAreaCoverageArea $coverageArea ): self
  81.         {
  82.             if ( !$this->coverageAreas->contains$coverageArea ) ) {
  83.                 $this->coverageAreas[] = $coverageArea;
  84.                 $coverageArea->addDepartment$this );
  85.             }
  86.             return $this;
  87.         }
  88.         public function removeCoverageAreaCoverageArea $coverageArea ): self
  89.         {
  90.             if ( $this->coverageAreas->removeElement$coverageArea ) ) {
  91.                 $coverageArea->removeDepartment$this );
  92.             }
  93.             return $this;
  94.         }
  95.     }