src/Entity/User/Address/Address.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\User\Address;
  3. use App\Repository\User\Address\AddressRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Timestampable\Traits\TimestampableEntity;
  6. use Ramsey\Uuid\Doctrine\UuidGenerator;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Serializer\Annotation\SerializedName;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\InheritanceType("SINGLE_TABLE")
  12.  * @ORM\DiscriminatorColumn(name="discr", type="string")
  13.  * @ORM\DiscriminatorMap({
  14.  *     "home" = "Home",
  15.  *     "delivery" = "Delivery",
  16.  *     "order" = "Order",
  17.  * })
  18.  *
  19.  * @ORM\Entity(repositoryClass=AddressRepository::class)
  20.  */
  21. abstract class Address
  22. {
  23.     /**
  24.      * Hook timestampable behavior
  25.      * updates createdAt, updatedAt fields
  26.      */
  27.     use TimestampableEntity;
  28.     /**
  29.      * @ORM\Id
  30.      * @ORM\Column(type="uuid", unique=true)
  31.      * @ORM\GeneratedValue(strategy="CUSTOM")
  32.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  33.      * @SerializedName("id")
  34.      * @Assert\Uuid()
  35.      * @Groups({
  36.      *     "Order:output",
  37.      *     "User:io",
  38.      *     "put_address_home",
  39.      *     "put_address_delivery",
  40.      *     "AddressHome:io",
  41.      *     "AddressDelivery:io",
  42.      * })
  43.      */
  44.     private string $id;
  45.     /**
  46.      * @ORM\Column(type="string", length=38)
  47.      * @SerializedName("street")
  48.      * @Assert\NotBlank()
  49.      * @Assert\Length(min="1", max="38")
  50.      * @Groups({
  51.      *     "Order:output",
  52.      *     "User:io",
  53.      *     "put_address_home",
  54.      *     "put_address_delivery",
  55.      *     "AddressHome:io",
  56.      *     "AddressDelivery:io",
  57.      * })
  58.      */
  59.     private string $street;
  60.     /**
  61.      * @ORM\Column(type="string", length=38, nullable=true)
  62.      * @SerializedName("complement")
  63.      * @Groups({
  64.      *     "Order:output",
  65.      *     "User:io",
  66.      *     "put_address_home",
  67.      *     "put_address_delivery",
  68.      *     "AddressHome:io",
  69.      *     "AddressDelivery:io",
  70.      * })
  71.      */
  72.     private ?string $complement null;
  73.     /**
  74.      * @ORM\Column(type="string", length=5)
  75.      * @SerializedName("postal_code")
  76.      * @Assert\NotBlank()
  77.      * @Assert\Length(min="5", max="5")
  78.      * @Assert\Type(type="numeric")
  79.      * @Groups({
  80.      *     "Order:output",
  81.      *     "User:io",
  82.      *     "put_address_home",
  83.      *     "put_address_delivery",
  84.      *     "AddressHome:io",
  85.      *     "AddressDelivery:io",
  86.      * })
  87.      */
  88.     private string $postalCode;
  89.     /**
  90.      * @ORM\Column(type="string", length=38)
  91.      * @SerializedName("city")
  92.      * @Assert\NotBlank()
  93.      * @Assert\Length(min="1", max="38")
  94.      * @Groups({
  95.      *     "Order:output",
  96.      *     "User:io",
  97.      *     "put_address_home",
  98.      *     "put_address_delivery",
  99.      *     "AddressHome:io",
  100.      *     "AddressDelivery:io",
  101.      * })
  102.      * @Assert\Regex("/^[a-zA-Z-ëêéèâàäôïîç ]*$/",
  103.      *     message = "Numbers or special characters are not allowed")
  104.      */
  105.     private string $city;
  106.     /**
  107.      * @ORM\Column(type="string", length=2)
  108.      * @SerializedName("country_code")
  109.      * @Assert\NotBlank()
  110.      * @Assert\Country()
  111.      */
  112.     private string $countryCode 'FR';
  113.     /**
  114.      * @ORM\Column(type="boolean")
  115.      * @SerializedName("favorite")
  116.      * @Groups({
  117.      *     "User:io",
  118.      *     "put_address_home",
  119.      *     "put_address_delivery",
  120.      *     "AddressHome:io",
  121.      *     "AddressDelivery:io",
  122.      * })
  123.      */
  124.     private bool $favorite;
  125.     /**
  126.      * @return string
  127.      */
  128.     public function getId(): ?string
  129.     {
  130.         return $this->id;
  131.     }
  132.     public function getStreet(): ?string
  133.     {
  134.         return $this->street;
  135.     }
  136.     public function setStreet(string $street): self
  137.     {
  138.         $this->street $street;
  139.         return $this;
  140.     }
  141.     public function getComplement(): ?string
  142.     {
  143.         return $this->complement;
  144.     }
  145.     public function setComplement(?string $complement): self
  146.     {
  147.         $this->complement $complement;
  148.         return $this;
  149.     }
  150.     public function getPostalCode(): ?string
  151.     {
  152.         return $this->postalCode;
  153.     }
  154.     public function setPostalCode(string $postalCode): self
  155.     {
  156.         $this->postalCode $postalCode;
  157.         return $this;
  158.     }
  159.     public function getCity(): ?string
  160.     {
  161.         return $this->city;
  162.     }
  163.     public function setCity(string $city): self
  164.     {
  165.         $this->city $city;
  166.         return $this;
  167.     }
  168.     public function getCountryCode(): ?string
  169.     {
  170.         return $this->countryCode;
  171.     }
  172.     public function setCountryCode(string $countryCode): self
  173.     {
  174.         $this->countryCode $countryCode;
  175.         return $this;
  176.     }
  177.     public function getFavorite(): ?bool
  178.     {
  179.         return $this->favorite;
  180.     }
  181.     public function setFavorite(bool $favorite): self
  182.     {
  183.         $this->favorite $favorite;
  184.         return $this;
  185.     }
  186. }