src/Entity/Address.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AddressRepository;
  4. use App\Trait\DateTrait;
  5. use App\Trait\DeletableTrait;
  6. use DateTimeImmutable;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Validator\Constraints\NotBlank;
  11. #[ORM\Entity(repositoryClassAddressRepository::class)]
  12. class Address
  13. {
  14.     use DateTrait;
  15.     use DeletableTrait;
  16.     const TYPE_HOME 'address.type.home';
  17.     const TYPE_WORK 'address.type.work';
  18.     const TYPE_DELIVERY 'address.type.delivery';
  19.     const TYPE_OTHER 'address.type.other';
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue]
  22.     #[ORM\Column]
  23.     #[Groups(['establishment:view''order:list'])]
  24.     private ?int $id null;
  25.     #[ORM\Column(length255)]
  26.     #[Groups(['establishment:view''establishment:register''order:list'])]
  27.     private ?string $country null;
  28.     #[ORM\Column(length255)]
  29.     #[Groups(['establishment:view''establishment:register''order:list'])]
  30.     private ?string $city null;
  31.     #[ORM\Column(length255)]
  32.     #[Groups(['establishment:view''establishment:register''order:list'])]
  33.     private ?string $commune null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     #[Groups(['establishment:view''establishment:register''order:list'])]
  36.     private ?string $district null;
  37.     #[ORM\Column(length255)]
  38.     #[Groups(['establishment:view''establishment:register''order:list'])]
  39.     private ?string $street null;
  40.     #[ORM\Column(length10,  nullabletrue)]
  41.     #[Groups(['establishment:view''establishment:register''order:list'])]
  42.     private ?string $number null;
  43.     #[ORM\Column]
  44.     private ?bool $isDefault false;
  45.     #[Assert\NotBlank]
  46.     #[Assert\NotNull]
  47.     #[ORM\Column(length255)]
  48.     private ?string $type "address.type.home";
  49.     #[ORM\ManyToOne(inversedBy'addresses')]
  50.     private ?Client $client null;
  51.     #[ORM\ManyToOne(inversedBy'addresses')]
  52.     private ?Employee $employee null;
  53.     public function __construct()
  54.     {
  55.         if (is_null($this->createdAt)) $this->createdAt = new DateTimeImmutable();
  56.         $this->updatedAt = new DateTimeImmutable();
  57.     }
  58.     public static function getTypes(): array
  59.     {
  60.         return [
  61.             self::TYPE_HOME,
  62.             self::TYPE_WORK,
  63.             self::TYPE_DELIVERY,
  64.             self::TYPE_OTHER,
  65.         ];
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getCountry(): ?string
  72.     {
  73.         return $this->country;
  74.     }
  75.     public function setCountry(string $country): self
  76.     {
  77.         $this->country $country;
  78.         return $this;
  79.     }
  80.     public function getCity(): ?string
  81.     {
  82.         return $this->city;
  83.     }
  84.     public function setCity(string $city): self
  85.     {
  86.         $this->city $city;
  87.         return $this;
  88.     }
  89.     public function getCommune(): ?string
  90.     {
  91.         return $this->commune;
  92.     }
  93.     public function setCommune(string $commune): self
  94.     {
  95.         $this->commune $commune;
  96.         return $this;
  97.     }
  98.     public function getDistrict(): ?string
  99.     {
  100.         return $this->district;
  101.     }
  102.     public function setDistrict(?string $district): self
  103.     {
  104.         $this->district $district;
  105.         return $this;
  106.     }
  107.     public function getStreet(): ?string
  108.     {
  109.         return $this->street;
  110.     }
  111.     public function setStreet(string $street): self
  112.     {
  113.         $this->street $street;
  114.         return $this;
  115.     }
  116.     public function getNumber(): ?string
  117.     {
  118.         return $this->number;
  119.     }
  120.     public function setNumber(string $number): self
  121.     {
  122.         $this->number $number;
  123.         return $this;
  124.     }
  125.     public function __toString(): string
  126.     {
  127.         return "$this->number $this->street$this->district $this->commune $this->city$this->country";
  128.     }
  129.     public function isIsDefault(): ?bool
  130.     {
  131.         return $this->isDefault;
  132.     }
  133.     public function setIsDefault(bool $isDefault): static
  134.     {
  135.         $this->isDefault $isDefault;
  136.         return $this;
  137.     }
  138.     public function getType(): ?string
  139.     {
  140.         return $this->type;
  141.     }
  142.     public function setType(string $type): static
  143.     {
  144.         $this->type $type;
  145.         return $this;
  146.     }
  147.     public function getClient(): ?Client
  148.     {
  149.         return $this->client;
  150.     }
  151.     public function setClient(?Client $client): static
  152.     {
  153.         $this->client $client;
  154.         return $this;
  155.     }
  156.     public function getEmployee(): ?Employee
  157.     {
  158.         return $this->employee;
  159.     }
  160.     public function setEmployee(?Employee $employee): static
  161.     {
  162.         $this->employee $employee;
  163.         return $this;
  164.     }
  165. }