<?phpnamespace App\Flexy\ShopBundle\Entity\Shipping;use ApiPlatform\Core\Annotation\ApiResource;use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;use App\Repository\Flexy\ShopBundle\Entity\Shipping\DepartementRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=DepartementRepository::class) */#[ApiResource]class Departement{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="text", nullable=true) */ private $description; /** * @ORM\ManyToOne(targetEntity=City::class, inversedBy="departements") */ private $city; /** * @ORM\OneToMany(targetEntity=CustomerAddress::class, mappedBy="departement") */ private $customerAddresses; public function __construct() { $this->customerAddresses = new ArrayCollection(); } public function __toString() { return $this->name; } 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 getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getCity(): ?City { return $this->city; } public function setCity(?City $city): self { $this->city = $city; return $this; } /** * @return Collection<int, CustomerAddress> */ public function getCustomerAddresses(): Collection { return $this->customerAddresses; } public function addCustomerAddress(CustomerAddress $customerAddress): self { if (!$this->customerAddresses->contains($customerAddress)) { $this->customerAddresses[] = $customerAddress; $customerAddress->setDepartement($this); } return $this; } public function removeCustomerAddress(CustomerAddress $customerAddress): self { if ($this->customerAddresses->removeElement($customerAddress)) { // set the owning side to null (unless already changed) if ($customerAddress->getDepartement() === $this) { $customerAddress->setDepartement(null); } } return $this; }}