src/Entity/Geographical/Address.php line 25

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Entity\Geographical;
  12. use App\Entity\Customer\Customer;
  13. use App\Entity\IdentifiableTrait;
  14. use App\Repository\Geographical\AddressRepository;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Sylius\Component\Resource\Model\ResourceInterface;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. #[ORM\Entity(repositoryClassAddressRepository::class)]
  19. #[ORM\Table(name'app_address')]
  20. class Address implements ResourceInterface
  21. {
  22.     use IdentifiableTrait;
  23.     #[ORM\ManyToOne(targetEntityCustomer::class, inversedBy'addresses')]
  24.     #[ORM\JoinColumn(name"customer_id"referencedColumnName"id"nullabletrueonDelete"CASCADE")]
  25.     private ?Customer $customer null;
  26.     #[ORM\Column(type'string'length100nullabletrue)]
  27.     #[Assert\Email]
  28.     private ?string $email null;
  29.     #[ORM\Column(type'string')]
  30.     #[Assert\NotBlank]
  31.     private ?string $firstName null;
  32.     #[ORM\Column(type'string')]
  33.     #[Assert\NotBlank]
  34.     private ?string $lastName null;
  35.     #[ORM\Column(type'string'nullabletrue)]
  36.     private ?string $phoneNumber null;
  37.     #[ORM\Column(type'string')]
  38.     #[Assert\NotBlank]
  39.     private ?string $street null;
  40.     #[ORM\Column(type'string'nullabletrue)]
  41.     private ?string $street2 null;
  42.     #[ORM\Column(type'string')]
  43.     #[Assert\NotBlank]
  44.     private ?string $city null;
  45.     #[ORM\Column(type'string'nullabletrue)]
  46.     private ?string $state null;
  47.     #[ORM\Column(type'string'length20)]
  48.     #[Assert\NotBlank]
  49.     private ?string $postcode null;
  50.     #[ORM\ManyToOne(targetEntityCountry::class)]
  51.     #[Assert\NotBlank]
  52.     #[ORM\JoinColumn(name"country_id"referencedColumnName"id")]
  53.     private $country null;
  54.     #[ORM\Column(type'datetime_immutable')]
  55.     private ?\DateTimeImmutable $createdAt null;
  56.     public function __construct()
  57.     {
  58.         $this->createdAt = new \DateTimeImmutable();
  59.     }
  60.     /**
  61.      * Get the value of customer
  62.      *
  63.      * @return ?Customer
  64.      */
  65.     public function getCustomer(): ?Customer
  66.     {
  67.         return $this->customer;
  68.     }
  69.     /**
  70.      * Set the value of customer
  71.      *
  72.      * @return self
  73.      */
  74.     public function setCustomer(?Customer $customer): self
  75.     {
  76.         $this->customer $customer;
  77.         return $this;
  78.     }
  79.     /**
  80.      * Get the value of email
  81.      *
  82.      * @return ?string
  83.      */
  84.     public function getEmail(): ?string
  85.     {
  86.         return $this->email;
  87.     }
  88.     /**
  89.      * Set the value of email
  90.      *
  91.      * @return self
  92.      */
  93.     public function setEmail(?string $email): self
  94.     {
  95.         $this->email $email;
  96.         return $this;
  97.     }
  98.     /**
  99.      * Get the value of firstName
  100.      *
  101.      * @return ?string
  102.      */
  103.     public function getFirstName(): ?string
  104.     {
  105.         return $this->firstName;
  106.     }
  107.     /**
  108.      * Set the value of firstName
  109.      *
  110.      * @return self
  111.      */
  112.     public function setFirstName(?string $firstName): self
  113.     {
  114.         $this->firstName $firstName;
  115.         return $this;
  116.     }
  117.     /**
  118.      * Get the value of lastName
  119.      *
  120.      * @return ?string
  121.      */
  122.     public function getLastName(): ?string
  123.     {
  124.         return $this->lastName;
  125.     }
  126.     /**
  127.      * Set the value of lastName
  128.      *
  129.      * @return self
  130.      */
  131.     public function setLastName(?string $lastName): self
  132.     {
  133.         $this->lastName $lastName;
  134.         return $this;
  135.     }
  136.     /**
  137.      * Get the value of phoneNumber
  138.      *
  139.      * @return ?string
  140.      */
  141.     public function getPhoneNumber(): ?string
  142.     {
  143.         return $this->phoneNumber;
  144.     }
  145.     /**
  146.      * Set the value of phoneNumber
  147.      *
  148.      * @return self
  149.      */
  150.     public function setPhoneNumber(?string $phoneNumber): self
  151.     {
  152.         $this->phoneNumber $phoneNumber;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get the value of street
  157.      *
  158.      * @return ?string
  159.      */
  160.     public function getStreet(): ?string
  161.     {
  162.         return $this->street;
  163.     }
  164.     /**
  165.      * Set the value of street
  166.      *
  167.      * @return self
  168.      */
  169.     public function setStreet(?string $street): self
  170.     {
  171.         $this->street $street;
  172.         return $this;
  173.     }
  174.     /**
  175.      * Get the value of street2
  176.      *
  177.      * @return ?string
  178.      */
  179.     public function getStreet2(): ?string
  180.     {
  181.         return $this->street2;
  182.     }
  183.     /**
  184.      * Set the value of street2
  185.      *
  186.      * @return self
  187.      */
  188.     public function setStreet2(?string $street2): self
  189.     {
  190.         $this->street2 $street2;
  191.         return $this;
  192.     }
  193.     /**
  194.      * Get the value of city
  195.      *
  196.      * @return ?string
  197.      */
  198.     public function getCity(): ?string
  199.     {
  200.         return $this->city;
  201.     }
  202.     /**
  203.      * Set the value of city
  204.      *
  205.      * @return self
  206.      */
  207.     public function setCity(?string $city): self
  208.     {
  209.         $this->city $city;
  210.         return $this;
  211.     }
  212.     /**
  213.      * Get the value of postcode
  214.      *
  215.      * @return ?string
  216.      */
  217.     public function getPostcode(): ?string
  218.     {
  219.         return $this->postcode;
  220.     }
  221.     /**
  222.      * Set the value of postcode
  223.      *
  224.      * @return self
  225.      */
  226.     public function setPostcode(?string $postcode): self
  227.     {
  228.         $this->postcode $postcode;
  229.         return $this;
  230.     }
  231.     /**
  232.      * Get the value of country
  233.      *
  234.      * @return ?Country
  235.      */
  236.     public function getCountry(): ?Country
  237.     {
  238.         return $this->country;
  239.     }
  240.     /**
  241.      * Set the value of country
  242.      *
  243.      * @return self
  244.      */
  245.     public function setCountry(?Country $country): self
  246.     {
  247.         $this->country $country;
  248.         return $this;
  249.     }
  250.     /**
  251.      * Get the value of createdAt
  252.      *
  253.      * @return ?\DateTimeImmutable
  254.      */
  255.     public function getCreatedAt(): ?\DateTimeImmutable
  256.     {
  257.         return $this->createdAt;
  258.     }
  259.     /**
  260.      * Set the value of createdAt
  261.      *
  262.      * @return self
  263.      */
  264.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  265.     {
  266.         $this->createdAt $createdAt;
  267.         return $this;
  268.     }
  269.     /**
  270.      * @return string|null
  271.      */
  272.     public function getState(): ?string
  273.     {
  274.         return $this->state;
  275.     }
  276.     /**
  277.      * @param string|null $state
  278.      */
  279.     public function setState(?string $state): void
  280.     {
  281.         $this->state $state;
  282.     }
  283.     public function getFullName(): string
  284.     {
  285.         return trim(sprintf('%s %s'$this->firstName$this->lastName));
  286.     }
  287. }