src/Entity/Order.php line 9

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Symfony\Component\Validator\Constraints as Assert;
  4. use JsonSerializable;
  5. class Order implements JsonSerializable
  6. {
  7.     /**
  8.      * @Assert\Type("App\Entity\Address")
  9.      * @Assert\Valid()
  10.      */
  11.     private Address $addressA;
  12.     /**
  13.      * @Assert\Type("App\Entity\Coordinates")
  14.      * @Assert\Valid()
  15.      */
  16.     private Coordinates $coordinatesA;
  17.     /**
  18.      * @Assert\Type("App\Entity\OrderTime")
  19.      * @Assert\Valid()
  20.      */
  21.     private OrderTime $timeA;
  22.     /**
  23.      * @Assert\Type("App\Entity\Address")
  24.      * @Assert\Valid()
  25.      */
  26.     private Address $addressB;
  27.     /**
  28.      * @Assert\Type("App\Entity\Coordinates")
  29.      * @Assert\Valid()
  30.      */
  31.     private Coordinates $coordinatesB;
  32.     /**
  33.      * @Assert\Type("App\Entity\OrderTime")
  34.      * @Assert\Valid()
  35.      */
  36.     private OrderTime $timeB;
  37.     /**
  38.      * @Assert\Type("string")
  39.      *
  40.      * @Assert\NotBlank(
  41.      * message="Pole nesmí být prázdné."
  42.      * )
  43.      * @Assert\Length(
  44.      *      min = 1,
  45.      *      minMessage = "Vložte validní hodnotu.",
  46.      * )
  47.      * @Assert\Regex(
  48.      *  pattern="/[0-9]/",
  49.      *  message="Hodnota není validní."
  50.      * )
  51.      */
  52.     private $price;
  53.     /**
  54.      * @Assert\Type("App\Entity\Address")
  55.      * @Assert\Valid()
  56.      */
  57.     private Address $addressF;
  58.     /**
  59.      * @Assert\Type("string")
  60.      *
  61.      * @Assert\Length(
  62.      *      min = 2,
  63.      *      max = 50,
  64.      *      minMessage = "Vložte validní hodnotu.",
  65.      *      maxMessage = "Vložte validní hodnotu.",
  66.      * )
  67.      */
  68.     private $ic;
  69.     /**
  70.      * @Assert\Type("string")
  71.      *
  72.      * @Assert\Length(
  73.      *      min = 2,
  74.      *      max = 50,
  75.      *      minMessage = "Vložte validní hodnotu.",
  76.      *      maxMessage = "Vložte validní hodnotu.",
  77.      * )
  78.      */
  79.     private $dic;
  80.     /**
  81.      * @Assert\Type("string")
  82.      *
  83.      * @Assert\NotBlank(
  84.      * message="Pole nesmí být prázdné."
  85.      * )
  86.      *
  87.      * @Assert\Length(
  88.      *      min = 2,
  89.      *      max = 50,
  90.      *      minMessage = "Vložte validní e-mail.",
  91.      *      maxMessage = "Vložte validní e-mail.",
  92.      * )
  93.      */
  94.     private $email;
  95.     /**
  96.      * @Assert\Type("string")
  97.      *
  98.      * @Assert\Length(
  99.      *      max = 50,
  100.      *      maxMessage = "Vložte validní hodnotu.",
  101.      * )
  102.      */
  103.     private $company;
  104.     /**
  105.      * @Assert\NotBlank(
  106.      * message="Pole nesmí být prázdné."
  107.      * )
  108.      *
  109.      * @Assert\Length(
  110.      *      max = 50,
  111.      *      maxMessage = "Max 50 znaků.",
  112.      * )
  113.      */
  114.     private $weight;
  115.     /**
  116.      * @Assert\Type("string")
  117.      *
  118.      * @Assert\Length(
  119.      *      max = 20,
  120.      *      maxMessage = "Max 20 znaků.",
  121.      * )
  122.      */
  123.     private $note;
  124.     /**
  125.      * @Assert\Type("string")
  126.      *
  127.      * @Assert\NotBlank(
  128.      * message="Pole nesmí být prázdné."
  129.      * )
  130.      *
  131.      * @Assert\Length(
  132.      *      max = 70,
  133.      *      maxMessage = "Max 70 znaků.",
  134.      * )
  135.      */
  136.     private $contentOfPackage;
  137.     public function getAddressA(): ?Address
  138.     {
  139.         return $this->addressA;
  140.     }
  141.     public function setAddressA(Address $addressA): self
  142.     {
  143.         $this->addressA $addressA;
  144.         return $this;
  145.     }
  146.     public function getCoordinatesA(): ?Coordinates
  147.     {
  148.         return $this->coordinatesA;
  149.     }
  150.     public function setCoordinatesA(Coordinates $coordinatesA): self
  151.     {
  152.         $this->coordinatesA $coordinatesA;
  153.         return $this;
  154.     }
  155.     public function getTimeA(): ?OrderTime
  156.     {
  157.         return $this->timeA;
  158.     }
  159.     public function setTimeA(OrderTime $timeA): self
  160.     {
  161.         $this->timeA $timeA;
  162.         return $this;
  163.     }
  164.     public function getAddressB(): ?Address
  165.     {
  166.         return $this->addressB;
  167.     }
  168.     public function setAddressB(Address $addressB): self
  169.     {
  170.         $this->addressB $addressB;
  171.         return $this;
  172.     }
  173.     public function getCoordinatesB(): ?Coordinates
  174.     {
  175.         return $this->coordinatesB;
  176.     }
  177.     public function setCoordinatesB(Coordinates $coordinatesB): self
  178.     {
  179.         $this->coordinatesB $coordinatesB;
  180.         return $this;
  181.     }
  182.     public function getTimeB(): ?OrderTime
  183.     {
  184.         return $this->timeB;
  185.     }
  186.     public function setTimeB(OrderTime $timeB): self
  187.     {
  188.         $this->timeB $timeB;
  189.         return $this;
  190.     }
  191.     public function getPrice(): ?string
  192.     {
  193.         return $this->price;
  194.     }
  195.     public function setPrice(string $price): self
  196.     {
  197.         $this->price $price;
  198.         return $this;
  199.     }
  200.     public function getAddressF(): ?Address
  201.     {
  202.         return $this->addressF;
  203.     }
  204.     public function setAddressF(Address $addressF): self
  205.     {
  206.         $this->addressF $addressF;
  207.         return $this;
  208.     }
  209.     public function getIc(): ?string
  210.     {
  211.         return $this->ic;
  212.     }
  213.     public function setIc(string $ic): self
  214.     {
  215.         $this->ic $ic;
  216.         return $this;
  217.     }
  218.     public function getDic(): ?string
  219.     {
  220.         return $this->dic;
  221.     }
  222.     public function setDic(?string $dic): self
  223.     {
  224.         $this->dic $dic;
  225.         return $this;
  226.     }
  227.     public function getEmail(): ?string
  228.     {
  229.         return $this->email;
  230.     }
  231.     public function setEmail(string $email): self
  232.     {
  233.         $this->email $email;
  234.         return $this;
  235.     }
  236.     public function getCompany(): ?string
  237.     {
  238.         return $this->company;
  239.     }
  240.     public function setCompany(string $company): self
  241.     {
  242.         $this->company $company;
  243.         return $this;
  244.     }
  245.     public function getWeight(): ?string
  246.     {
  247.         return $this->weight;
  248.     }
  249.     public function setWeight(string $weight): self
  250.     {
  251.         $this->weight $weight;
  252.         return $this;
  253.     }
  254.     public function getNote(): ?string
  255.     {
  256.         return $this->note;
  257.     }
  258.     public function setNote(string $note): self
  259.     {
  260.         $this->note $note;
  261.         return $this;
  262.     }
  263.     public function getContentOfPackage(): ?string
  264.     {
  265.         return $this->contentOfPackage;
  266.     }
  267.     public function setContentOfPackage(string $contentOfPackage): self
  268.     {
  269.         $this->contentOfPackage $contentOfPackage;
  270.         return $this;
  271.     }
  272.     /**
  273.      * @return mixed
  274.      */
  275.     public function jsonSerialize() : mixed
  276.     {
  277.         return [
  278.             'email' => $this->email,
  279.             'pickup' => [
  280.                 'time' => $this->timeA,
  281.                 'address' => $this->addressA,
  282.                 'coordinates' => $this->coordinatesA,
  283.             ],
  284.             'delivery' => [
  285.                 'time' => $this->timeB,
  286.                 'address' => $this->addressB,
  287.                 'coordinates' => $this->coordinatesB,
  288.             ],
  289.             'invoice' => [
  290.                 'address' => $this->addressF,
  291.                 'company_name' => $this->company,
  292.                 'tax_id' => $this->dic,
  293.                 'business_id' => $this->ic,
  294.             ],
  295.             'weight' => $this->weight,
  296.             'note' => $this->note,
  297.             'content_of_package' => $this->contentOfPackage,
  298.             'price' => $this->price,
  299.         ];
  300.     }
  301. }