src/Flexy/ShopBundle/Entity/Shipping/Departement.php line 14
<?php
namespace App\Flexy\ShopBundle\Entity\Shipping;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;
use App\Flexy\ShopBundle\Repository\Shipping\DepartementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: DepartementRepository::class)]
class Departement implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $name = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(targetEntity: City::class, inversedBy: 'departements')]
private ?\App\Flexy\ShopBundle\Entity\Shipping\City $city = null;
#[ORM\OneToMany(targetEntity: CustomerAddress::class, mappedBy: 'departement')]
private \Doctrine\Common\Collections\Collection|array $customerAddresses;
public function __construct()
{
$this->customerAddresses = new ArrayCollection();
}
public function __toString(): string
{
return (string) $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;
}
}