src/Flexy/ShopBundle/Entity/Shipping/Departement.php line 14

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;
  5. use App\Flexy\ShopBundle\Repository\Shipping\DepartementRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ApiResource]
  10. #[ORM\Entity(repositoryClassDepartementRepository::class)]
  11. class Departement implements \Stringable
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(type'text'nullabletrue)]
  20.     private ?string $description null;
  21.     #[ORM\ManyToOne(targetEntityCity::class, inversedBy'departements')]
  22.     private ?\App\Flexy\ShopBundle\Entity\Shipping\City $city null;
  23.     #[ORM\OneToMany(targetEntityCustomerAddress::class, mappedBy'departement')]
  24.     private \Doctrine\Common\Collections\Collection|array $customerAddresses;
  25.     public function __construct()
  26.     {
  27.         $this->customerAddresses = new ArrayCollection();
  28.     }
  29.     public function __toString(): string
  30.     {
  31.         return (string) $this->name;
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getDescription(): ?string
  47.     {
  48.         return $this->description;
  49.     }
  50.     public function setDescription(?string $description): self
  51.     {
  52.         $this->description $description;
  53.         return $this;
  54.     }
  55.     public function getCity(): ?City
  56.     {
  57.         return $this->city;
  58.     }
  59.     public function setCity(?City $city): self
  60.     {
  61.         $this->city $city;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection<int, CustomerAddress>
  66.      */
  67.     public function getCustomerAddresses(): Collection
  68.     {
  69.         return $this->customerAddresses;
  70.     }
  71.     public function addCustomerAddress(CustomerAddress $customerAddress): self
  72.     {
  73.         if (!$this->customerAddresses->contains($customerAddress)) {
  74.             $this->customerAddresses[] = $customerAddress;
  75.             $customerAddress->setDepartement($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeCustomerAddress(CustomerAddress $customerAddress): self
  80.     {
  81.         if ($this->customerAddresses->removeElement($customerAddress)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($customerAddress->getDepartement() === $this) {
  84.                 $customerAddress->setDepartement(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89. }