<?php namespace App\Entity; use App\Repository\DepartmentRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=DepartmentRepository::class) */ class Department { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=3) */ private $code; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="string", length=255) */ private $slug; /** * @ORM\ManyToMany(targetEntity=CoverageArea::class, mappedBy="departments") */ private $coverageAreas; public function __construct() { $this->coverageAreas = new ArrayCollection(); } public function __toString() { return $this->name . ' (' . $this->code . ')'; } public function getId(): ?int { return $this->id; } public function getCode(): ?string { return $this->code; } public function setCode( string $code ): self { $this->code = $code; return $this; } public function getName(): ?string { return $this->name; } public function setName( string $name ): self { $this->name = $name; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug( string $slug ): self { $this->slug = $slug; return $this; } /** * @return Collection|CoverageArea[] */ public function getCoverageAreas(): Collection { return $this->coverageAreas; } public function addCoverageArea( CoverageArea $coverageArea ): self { if ( !$this->coverageAreas->contains( $coverageArea ) ) { $this->coverageAreas[] = $coverageArea; $coverageArea->addDepartment( $this ); } return $this; } public function removeCoverageArea( CoverageArea $coverageArea ): self { if ( $this->coverageAreas->removeElement( $coverageArea ) ) { $coverageArea->removeDepartment( $this ); } return $this; } }