src/Entity/Order.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Dto\ShoppingCart;
  4. use App\Repository\OrderRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  7. use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
  8. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  9. use Symfony\Component\Serializer\Serializer;
  10. /**
  11.  * @ORM\Entity(repositoryClass=OrderRepository::class)
  12.  *
  13.  * @ORM\Table(name="`order`")
  14.  *
  15.  * @ORM\HasLifecycleCallbacks()
  16.  */
  17. class Order {
  18.     use MetaTrait;
  19.     public const STATUS_CANCELLED = -1;
  20.     public const STATUS_NEW 0;
  21.     public const STATUS_PENDING 1;
  22.     public const STATUS_SCHEDULED 2;
  23.     public const STATUS_DONE 3;
  24.     /**
  25.      * @ORM\Id
  26.      *
  27.      * @ORM\GeneratedValue
  28.      *
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="orders")
  34.      *
  35.      * @ORM\JoinColumn(nullable=false)
  36.      */
  37.     private $user;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=Tenant::class, inversedBy="orders")
  40.      *
  41.      * @ORM\JoinColumn(nullable=false)
  42.      */
  43.     private $tenant;
  44.     /**
  45.      * @ORM\Column(type="text", nullable=true)
  46.      */
  47.     private $shoppingCart;
  48.     /**
  49.      * @ORM\Column(type="boolean")
  50.      */
  51.     private $terms;
  52.     /**
  53.      * @ORM\Column(type="string", length=255, nullable=true)
  54.      */
  55.     private $careFacility;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $invoiceStreet;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $invoiceHouseNumber;
  64.     /**
  65.      * @ORM\Column(type="integer", nullable=true)
  66.      */
  67.     private $invoiceZip;
  68.     /**
  69.      * @ORM\Column(type="string", length=255, nullable=true)
  70.      */
  71.     private $invoiceCity;
  72.     /**
  73.      * @ORM\Column(type="smallint")
  74.      */
  75.     private $status;
  76.     /**
  77.      * @ORM\Column(type="float", nullable=true)
  78.      */
  79.     private $totalPrice;
  80.     /**
  81.      * @ORM\Column(type="float", nullable=true)
  82.      */
  83.     private $totalRecurringPrice;
  84.     /**
  85.      * @ORM\Column(type="string", length=255)
  86.      */
  87.     private $orderNumber;
  88.     /**
  89.      * @ORM\Column(type="string", length=255)
  90.      */
  91.     private $kimRegId;
  92.     /**
  93.      * @ORM\Column(type="string", length=255)
  94.      */
  95.     private $externalOrderId;
  96.     public function getId(): ?int {
  97.         return $this->id;
  98.     }
  99.     public function getUser(): ?User {
  100.         return $this->user;
  101.     }
  102.     public function setUser(?User $user): self {
  103.         $this->user $user;
  104.         return $this;
  105.     }
  106.     public function getTenant(): ?Tenant {
  107.         return $this->tenant;
  108.     }
  109.     public function setTenant(?Tenant $tenant): self {
  110.         $this->tenant $tenant;
  111.         return $this;
  112.     }
  113.     public function getShoppingCart(): ?ShoppingCart {
  114.         $serializer = new Serializer(
  115.             [new ObjectNormalizer(nullnullnullnullnullnull, [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function($object) {
  116.                 return $object->getId();
  117.             }])],
  118.             [new JsonEncoder()]
  119.         );
  120.         return $serializer->deserialize(
  121.             $this->shoppingCart,
  122.             ShoppingCart::class,
  123.             'json'
  124.         );
  125.     }
  126.     public function setShoppingCart(?ShoppingCart $shoppingCart): self {
  127.         $serializer = new Serializer(
  128.             [new ObjectNormalizer(nullnullnullnullnullnull, [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function($object) {
  129.                 return $object->getId();
  130.             }])],
  131.             [new JsonEncoder()]
  132.         );
  133.         $this->shoppingCart $serializer->serialize(
  134.             $shoppingCart,
  135.             'json'
  136.         );
  137.         return $this;
  138.     }
  139.     public function getTerms(): ?bool {
  140.         return $this->terms;
  141.     }
  142.     public function setTerms(bool $terms): self {
  143.         $this->terms $terms;
  144.         return $this;
  145.     }
  146.     public function getCareFacility(): ?string {
  147.         return $this->careFacility;
  148.     }
  149.     public function setCareFacility(?string $careFacility): self {
  150.         $this->careFacility $careFacility;
  151.         return $this;
  152.     }
  153.     public function getInvoiceStreet(): ?string {
  154.         return $this->invoiceStreet;
  155.     }
  156.     public function setInvoiceStreet(?string $invoiceStreet): self {
  157.         $this->invoiceStreet $invoiceStreet;
  158.         return $this;
  159.     }
  160.     public function getInvoiceHouseNumber(): ?string {
  161.         return $this->invoiceHouseNumber;
  162.     }
  163.     public function setInvoiceHouseNumber(string $invoiceHouseNumber): self {
  164.         $this->invoiceHouseNumber $invoiceHouseNumber;
  165.         return $this;
  166.     }
  167.     public function getInvoiceZip(): ?int {
  168.         return $this->invoiceZip;
  169.     }
  170.     public function setInvoiceZip(int $invoiceZip): self {
  171.         $this->invoiceZip $invoiceZip;
  172.         return $this;
  173.     }
  174.     public function getInvoiceCity(): ?string {
  175.         return $this->invoiceCity;
  176.     }
  177.     public function setInvoiceCity(string $invoiceCity): self {
  178.         $this->invoiceCity $invoiceCity;
  179.         return $this;
  180.     }
  181.     /**
  182.      * @ORM\PrePersist
  183.      */
  184.     public function setDefaults(): self {
  185.         return $this
  186.             ->setCreatedAt(new \DateTime())
  187.         ;
  188.     }
  189.     /**
  190.      * @ORM\PreUpdate
  191.      */
  192.     public function setModified(): self {
  193.         return $this
  194.             ->setModifiedAt(new \DateTime())
  195.         ;
  196.     }
  197.     public function getStatus(): ?int {
  198.         return $this->status;
  199.     }
  200.     public function setStatus(int $status): self {
  201.         $this->status $status;
  202.         return $this;
  203.     }
  204.     public function getTotalPrice(): ?float {
  205.         return $this->totalPrice;
  206.     }
  207.     public function setTotalPrice(float $totalPrice): self {
  208.         $this->totalPrice $totalPrice;
  209.         return $this;
  210.     }
  211.     public function getTotalRecurringPrice(): ?float {
  212.         return $this->totalRecurringPrice;
  213.     }
  214.     public function setTotalRecurringPrice(?float $totalRecurringPrice): self {
  215.         $this->totalRecurringPrice $totalRecurringPrice;
  216.         return $this;
  217.     }
  218.     public function getOrderNumber(): ?string {
  219.         return $this->orderNumber;
  220.     }
  221.     public function setOrderNumber(string $orderNumber): self {
  222.         $this->orderNumber $orderNumber;
  223.         return $this;
  224.     }
  225.     public function getInvoiceAddress() {
  226.         return $this->getInvoiceStreet() . ' ' $this->getInvoiceHouseNumber() . ' ' $this->getInvoiceZip() . ' ' $this->getInvoiceCity();
  227.     }
  228.     public function getExternalOrderId(): ?string {
  229.         return $this->externalOrderId;
  230.     }
  231.     public function setExternalOrderId(string $externalOrderId): self {
  232.         $this->externalOrderId $externalOrderId;
  233.         return $this;
  234.     }
  235.     public function getKimRegId(): ?string {
  236.         return $this->kimRegId;
  237.     }
  238.     public function setKimRegId(string $kimRegId): self {
  239.         $this->kimRegId $kimRegId;
  240.         return $this;
  241.     }
  242. }