src/Entity/Customer.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CustomerRepository;
  4. use App\Trait\Identity;
  5. use App\Trait\Person;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Timestampable\Traits\TimestampableEntity;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ORM\InheritanceType('JOINED')]
  14. #[ORM\DiscriminatorColumn(name"dtype"type"string")]
  15. #[ORM\DiscriminatorMap(['moral' => CustomerMoral::class, 'physical' => CustomerPhysical::class])]
  16. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  17. #[UniqueEntity(['email'])]
  18. class Customer
  19. {
  20.     use TimestampableEntity;
  21.     use Person;
  22.     use Identity;
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column(type'integer')]
  26.     #[Groups(['customer:read'])]
  27.     private ?int $id;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $auxiliaryCode null// for accountancy (optional)
  30.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  31.     private ?string $note null;
  32.     #[ORM\Column(length3nullabletrue)]
  33.     #[Groups(['customer:read'])]
  34.     private ?string $currency;
  35.     #[ORM\ManyToOne]
  36.     private ?Market $market null;
  37.     #[ORM\ManyToOne]
  38.     private ?City $city null;
  39.     #[ORM\OneToMany(mappedBy'customer'targetEntityCustomerInfoType::class, orphanRemovaltrue)]
  40.     private Collection $customerInfoTypes;
  41.     #[ORM\ManyToOne(targetEntityself::class)]
  42.     private ?self $parent null;
  43.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  44.     private ?FileData $logo null;
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?bool $isDefault null;
  47.     #[ORM\Column(typeTypes::BOOLEANnullabletrue)]
  48.     private ?bool $active null;
  49.     #[ORM\Column(nullabletrue)]
  50.     private ?bool $showAllHotelXml null;
  51.     #[ORM\OneToMany(mappedBy'customer'targetEntityCustomerAirlineXmlApi::class)]
  52.     private Collection $customerAirlineXmlApis;
  53.     public function __construct()
  54.     {
  55.         $this->customerInfoTypes = new ArrayCollection();
  56.         $this->customerAirlineXmlApis = new ArrayCollection();
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getCurrency(): ?string
  63.     {
  64.         return $this->currency;
  65.     }
  66.     public function setCurrency(?string $currency): self
  67.     {
  68.         $this->currency $currency;
  69.         return $this;
  70.     }
  71.     public function getMarket(): ?Market
  72.     {
  73.         return $this->market;
  74.     }
  75.     public function setMarket(?Market $market): self
  76.     {
  77.         $this->market $market;
  78.         return $this;
  79.     }
  80.     public function getAuxiliaryCode(): ?string
  81.     {
  82.         return $this->auxiliaryCode;
  83.     }
  84.     public function setAuxiliaryCode(?string $auxiliary_code): self
  85.     {
  86.         $this->auxiliaryCode $auxiliary_code;
  87.         return $this;
  88.     }
  89.     public function getNote(): ?string
  90.     {
  91.         return $this->note;
  92.     }
  93.     public function setNote(?string $note): self
  94.     {
  95.         $this->note $note;
  96.         return $this;
  97.     }
  98.     public function getCity(): ?City
  99.     {
  100.         return $this->city;
  101.     }
  102.     public function setCity(?City $city): self
  103.     {
  104.         $this->city $city;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, CustomerInfoType>
  109.      */
  110.     public function getCustomerInfoTypes(): Collection
  111.     {
  112.         return $this->customerInfoTypes;
  113.     }
  114.     public function addCustomerInfoType(CustomerInfoType $customerInfoType): self
  115.     {
  116.         if (!$this->customerInfoTypes->contains($customerInfoType)) {
  117.             $this->customerInfoTypes->add($customerInfoType);
  118.             $customerInfoType->setCustomer($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeCustomerInfoType(CustomerInfoType $customerInfoType): self
  123.     {
  124.         if ($this->customerInfoTypes->removeElement($customerInfoType)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($customerInfoType->getCustomer() === $this) {
  127.                 $customerInfoType->setCustomer(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getParent(): ?self
  133.     {
  134.         return $this->parent;
  135.     }
  136.     public function setParent(?self $parent): self
  137.     {
  138.         $this->parent $parent;
  139.         return $this;
  140.     }
  141.     public function getLogo(): ?FileData
  142.     {
  143.         return $this->logo;
  144.     }
  145.     public function setLogo(?FileData $logo): self
  146.     {
  147.         $this->logo $logo;
  148.         return $this;
  149.     }
  150.     public function isIsDefault(): ?bool
  151.     {
  152.         return $this->isDefault;
  153.     }
  154.     public function setIsDefault(?bool $isDefault): self
  155.     {
  156.         $this->isDefault $isDefault;
  157.         return $this;
  158.     }
  159.     public function getActive(): ?bool
  160.     {
  161.         return $this->active;
  162.     }
  163.     public function setActive(?bool $active): self
  164.     {
  165.         $this->active $active;
  166.         return $this;
  167.     }
  168.     public function __toString(): string
  169.     {
  170.         return $this->name;
  171.     }
  172.     public function getApiKey(): ?string
  173.     {
  174.         return hash('md5'$this->getId());
  175.     }
  176.     public function isShowAllHotelXml(): ?bool
  177.     {
  178.         return $this->showAllHotelXml;
  179.     }
  180.     public function setShowAllHotelXml(bool $showAllHotelXml): static
  181.     {
  182.         $this->showAllHotelXml $showAllHotelXml;
  183.         return $this;
  184.     }
  185.     public function getResellerMargin(): ?float
  186.     {
  187.         return 0;
  188.     }
  189.     public function getClass()  : string {
  190.         return "Customer";
  191.     }
  192.     /**
  193.      * @return Collection<int, CustomerAirlineXmlApi>
  194.      */
  195.     public function getCustomerAirlineXmlApis(): Collection
  196.     {
  197.         return $this->customerAirlineXmlApis;
  198.     }
  199.     public function addCustomerAirlineXmlApi(CustomerAirlineXmlApi $customerAirlineXmlApi): static
  200.     {
  201.         if (!$this->customerAirlineXmlApis->contains($customerAirlineXmlApi)) {
  202.             $this->customerAirlineXmlApis->add($customerAirlineXmlApi);
  203.             $customerAirlineXmlApi->setCustomer($this);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeCustomerAirlineXmlApi(CustomerAirlineXmlApi $customerAirlineXmlApi): static
  208.     {
  209.         if ($this->customerAirlineXmlApis->removeElement($customerAirlineXmlApi)) {
  210.             // set the owning side to null (unless already changed)
  211.             if ($customerAirlineXmlApi->getCustomer() === $this) {
  212.                 $customerAirlineXmlApi->setCustomer(null);
  213.             }
  214.         }
  215.         return $this;
  216.     }
  217. }