src/Entity/Gos/Country.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use JMS\Serializer\Annotation as JMS;
  8. /**
  9.  * @ORM\Table()
  10.  * @ORM\Entity(repositoryClass="App\Repository\CountryRepository")
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class Country
  14. {
  15.     /**
  16.      * @ORM\Column(type="integer")
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="IDENTITY")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="boolean", nullable=true)
  23.      * @JMS\Expose()
  24.      */
  25.     private $isActive;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      * @JMS\Expose()
  29.      */
  30.     private $name;
  31.     /**
  32.      * @Gedmo\Slug(fields={"name"})
  33.      * @ORM\Column(type="string", length=191, unique=true)
  34.      * @JMS\Expose()
  35.      */
  36.     private $slug;
  37.     /**
  38.      * @ORM\Column(type="string", length=3)
  39.      * @JMS\Expose()
  40.      */
  41.     private $alpha2;
  42.     /**
  43.      * @ORM\Column(type="string", length=3)
  44.      * @JMS\Expose()
  45.      */
  46.     private $alpha3;
  47.     /**
  48.      * @ORM\Column(type="string", length=3, nullable=true)
  49.      * @JMS\Expose()
  50.      */
  51.     private $ioc;
  52.     /**
  53.      * @ORM\Column(type="string", length=3, nullable=true)
  54.      * @JMS\Expose()
  55.      */
  56.     private $emoji;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\Currency", inversedBy="country")
  59.      * @ORM\JoinColumn()
  60.      */
  61.     private $currency;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\Language", inversedBy="country")
  64.      * @ORM\JoinColumn(name="language_id", referencedColumnName="id", onDelete="set null")
  65.      */
  66.     private $language;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity="Continent", inversedBy="country")
  69.      * @ORM\JoinColumn()
  70.      */
  71.     private $continent;
  72.     /**
  73.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\User", mappedBy="country")
  74.      */
  75.     private $user;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="country")
  78.      */
  79.     private $productVariants;
  80.     /**
  81.      * @ORM\OneToOne(targetEntity="CountrySettings", mappedBy="country")
  82.      */
  83.     private $countrySettings;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity="Cart", mappedBy="country")
  86.      */
  87.     private $carts;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity="Orders", mappedBy="country")
  90.      */
  91.     private $orders;
  92.     /**
  93.      * @ORM\ManyToMany(targetEntity="PaymentOptions", mappedBy="country")
  94.      */
  95.     private $paymentOptions;
  96.     /**
  97.      * @ORM\Column(type="datetime")
  98.      */
  99.     private $createdAt;
  100.     /**
  101.      * @ORM\Column(type="datetime", nullable=true)
  102.      */
  103.     private $updatedAt;
  104.     /**
  105.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariantPack", mappedBy="countries")
  106.      */
  107.     private $productVariantPacks;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=Address::class, mappedBy="deliveryAddressProductCountry")
  110.      */
  111.     private $deliveryAddressProducts;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=Address::class, mappedBy="country")
  114.      */
  115.     private $addresses;
  116.     /** @ORM\PrePersist() */
  117.     public function prePersist()
  118.     {
  119.         $this->createdAt = new \DateTime();
  120.     }
  121.     /** @ORM\PreUpdate() */
  122.     public function preUpdate()
  123.     {
  124.         $this->updatedAt = new \DateTime();
  125.     }
  126.     public function __toString()
  127.     {
  128.         return (string)$this->name;
  129.     }
  130.     /**
  131.      * Get id
  132.      *
  133.      * @return integer
  134.      */
  135.     public function getId()
  136.     {
  137.         return $this->id;
  138.     }
  139.     /**
  140.      * Set isActive
  141.      *
  142.      * @param boolean $isActive
  143.      * @return Country
  144.      */
  145.     public function setIsActive($isActive)
  146.     {
  147.         $this->isActive $isActive;
  148.         return $this;
  149.     }
  150.     /**
  151.      * Get isActive
  152.      *
  153.      * @return boolean
  154.      */
  155.     public function getIsActive()
  156.     {
  157.         return $this->isActive;
  158.     }
  159.     /**
  160.      * Set name
  161.      *
  162.      * @param string $name
  163.      * @return Country
  164.      */
  165.     public function setName($name)
  166.     {
  167.         $this->name $name;
  168.         return $this;
  169.     }
  170.     /**
  171.      * Get name
  172.      *
  173.      * @return string
  174.      */
  175.     public function getName()
  176.     {
  177.         return $this->name;
  178.     }
  179.     /**
  180.      * Set createdAt
  181.      *
  182.      * @param \DateTime $createdAt
  183.      * @return Country
  184.      */
  185.     public function setCreatedAt($createdAt)
  186.     {
  187.         $this->createdAt $createdAt;
  188.         return $this;
  189.     }
  190.     /**
  191.      * Get createdAt
  192.      *
  193.      * @return \DateTime
  194.      */
  195.     public function getCreatedAt()
  196.     {
  197.         return $this->createdAt;
  198.     }
  199.     /**
  200.      * Set updatedAt
  201.      *
  202.      * @param \DateTime $updatedAt
  203.      * @return Country
  204.      */
  205.     public function setUpdatedAt($updatedAt)
  206.     {
  207.         $this->updatedAt $updatedAt;
  208.         return $this;
  209.     }
  210.     /**
  211.      * Get updatedAt
  212.      *
  213.      * @return \DateTime
  214.      */
  215.     public function getUpdatedAt()
  216.     {
  217.         return $this->updatedAt;
  218.     }
  219.     /**
  220.      * Set continent
  221.      *
  222.      * @param \App\Entity\Gos\Continent $continent
  223.      * @return Country
  224.      */
  225.     public function setContinent(\App\Entity\Gos\Continent $continent null)
  226.     {
  227.         $this->continent $continent;
  228.         return $this;
  229.     }
  230.     /**
  231.      * Get continent
  232.      *
  233.      * @return \App\Entity\Gos\Continent
  234.      */
  235.     public function getContinent()
  236.     {
  237.         return $this->continent;
  238.     }
  239.     /**
  240.      * Set slug
  241.      *
  242.      * @param string $slug
  243.      * @return Country
  244.      */
  245.     public function setSlug($slug)
  246.     {
  247.         $this->slug $slug;
  248.         return $this;
  249.     }
  250.     /**
  251.      * Get slug
  252.      *
  253.      * @return string
  254.      */
  255.     public function getSlug()
  256.     {
  257.         return $this->slug;
  258.     }
  259.     /**
  260.      * Constructor
  261.      */
  262.     public function __construct()
  263.     {
  264.         $this->user = new \Doctrine\Common\Collections\ArrayCollection();
  265.         $this->productVariants = new ArrayCollection();
  266.         $this->carts = new ArrayCollection();
  267.         $this->orders = new ArrayCollection();
  268.         $this->paymentOptions = new ArrayCollection();
  269.         $this->productVariantPacks = new ArrayCollection();
  270.         $this->addresses = new ArrayCollection();
  271.     }
  272.     /**
  273.      * Add user
  274.      *
  275.      * @param \App\Entity\Gos\User $user
  276.      * @return Country
  277.      */
  278.     public function addUser(\App\Entity\Gos\User $user)
  279.     {
  280.         $this->user[] = $user;
  281.         return $this;
  282.     }
  283.     /**
  284.      * Remove user
  285.      *
  286.      * @param \App\Entity\Gos\User $user
  287.      */
  288.     public function removeUser(\App\Entity\Gos\User $user)
  289.     {
  290.         $this->user->removeElement($user);
  291.     }
  292.     /**
  293.      * Get user
  294.      *
  295.      * @return \Doctrine\Common\Collections\Collection
  296.      */
  297.     public function getUser()
  298.     {
  299.         return $this->user;
  300.     }
  301.     /**
  302.      * Set alpha2
  303.      *
  304.      * @param string $alpha2
  305.      *
  306.      * @return Country
  307.      */
  308.     public function setAlpha2($alpha2)
  309.     {
  310.         $this->alpha2 $alpha2;
  311.         return $this;
  312.     }
  313.     /**
  314.      * Get alpha2
  315.      *
  316.      * @return string
  317.      */
  318.     public function getAlpha2()
  319.     {
  320.         return $this->alpha2;
  321.     }
  322.     /**
  323.      * Set alpha3
  324.      *
  325.      * @param string $alpha3
  326.      *
  327.      * @return Country
  328.      */
  329.     public function setAlpha3($alpha3)
  330.     {
  331.         $this->alpha3 $alpha3;
  332.         return $this;
  333.     }
  334.     /**
  335.      * Get alpha3
  336.      *
  337.      * @return string
  338.      */
  339.     public function getAlpha3()
  340.     {
  341.         return $this->alpha3;
  342.     }
  343.     /**
  344.      * Set emoji
  345.      *
  346.      * @param string $emoji
  347.      *
  348.      * @return Country
  349.      */
  350.     public function setEmoji($emoji)
  351.     {
  352.         $this->emoji $emoji;
  353.         return $this;
  354.     }
  355.     /**
  356.      * Get emoji
  357.      *
  358.      * @return string
  359.      */
  360.     public function getEmoji()
  361.     {
  362.         return $this->emoji;
  363.     }
  364.     /**
  365.      * Set language
  366.      *
  367.      * @param \App\Entity\Gos\Language $language
  368.      *
  369.      * @return Country
  370.      */
  371.     public function setLanguage(\App\Entity\Gos\Language $language null)
  372.     {
  373.         $this->language $language;
  374.         return $this;
  375.     }
  376.     /**
  377.      * Get language
  378.      *
  379.      * @return \App\Entity\Gos\Language
  380.      */
  381.     public function getLanguage()
  382.     {
  383.         return $this->language;
  384.     }
  385.     /**
  386.      * Set ioc
  387.      *
  388.      * @param string $ioc
  389.      *
  390.      * @return Country
  391.      */
  392.     public function setIoc($ioc)
  393.     {
  394.         $this->ioc $ioc;
  395.         return $this;
  396.     }
  397.     /**
  398.      * Get ioc
  399.      *
  400.      * @return string
  401.      */
  402.     public function getIoc()
  403.     {
  404.         return $this->ioc;
  405.     }
  406.     /**
  407.      * @return Collection|ProductVariant[]
  408.      */
  409.     public function getProductVariants(): Collection
  410.     {
  411.         return $this->productVariants;
  412.     }
  413.     public function addProductVariant(ProductVariant $productVariant): self
  414.     {
  415.         if (!$this->productVariants->contains($productVariant)) {
  416.             $this->productVariants[] = $productVariant;
  417.             $productVariant->setCountry($this);
  418.         }
  419.         return $this;
  420.     }
  421.     public function removeProductVariant(ProductVariant $productVariant): self
  422.     {
  423.         if ($this->productVariants->contains($productVariant)) {
  424.             $this->productVariants->removeElement($productVariant);
  425.             // set the owning side to null (unless already changed)
  426.             if ($productVariant->getCountry() === $this) {
  427.                 $productVariant->setCountry(null);
  428.             }
  429.         }
  430.         return $this;
  431.     }
  432.     public function getCurrency(): ?Currency
  433.     {
  434.         return $this->currency;
  435.     }
  436.     public function setCurrency(?Currency $currency): self
  437.     {
  438.         $this->currency $currency;
  439.         return $this;
  440.     }
  441.     public function getCountrySettings(): ?CountrySettings
  442.     {
  443.         return $this->countrySettings;
  444.     }
  445.     public function setCountrySettings(?CountrySettings $countrySettings): self
  446.     {
  447.         $this->countrySettings $countrySettings;
  448.         // set (or unset) the owning side of the relation if necessary
  449.         $newCountry $countrySettings === null null $this;
  450.         if ($newCountry !== $countrySettings->getCountry()) {
  451.             $countrySettings->setCountry($newCountry);
  452.         }
  453.         return $this;
  454.     }
  455.     /**
  456.      * @return Collection|Cart[]
  457.      */
  458.     public function getCarts(): Collection
  459.     {
  460.         return $this->carts;
  461.     }
  462.     public function addCart(Cart $cart): self
  463.     {
  464.         if (!$this->carts->contains($cart)) {
  465.             $this->carts[] = $cart;
  466.             $cart->setCountry($this);
  467.         }
  468.         return $this;
  469.     }
  470.     public function removeCart(Cart $cart): self
  471.     {
  472.         if ($this->carts->contains($cart)) {
  473.             $this->carts->removeElement($cart);
  474.             // set the owning side to null (unless already changed)
  475.             if ($cart->getCountry() === $this) {
  476.                 $cart->setCountry(null);
  477.             }
  478.         }
  479.         return $this;
  480.     }
  481.     /**
  482.      * @return Collection|Orders[]
  483.      */
  484.     public function getOrders(): Collection
  485.     {
  486.         return $this->orders;
  487.     }
  488.     public function addOrder(Orders $order): self
  489.     {
  490.         if (!$this->orders->contains($order)) {
  491.             $this->orders[] = $order;
  492.             $order->setCountry($this);
  493.         }
  494.         return $this;
  495.     }
  496.     public function removeOrder(Orders $order): self
  497.     {
  498.         if ($this->orders->contains($order)) {
  499.             $this->orders->removeElement($order);
  500.             // set the owning side to null (unless already changed)
  501.             if ($order->getCountry() === $this) {
  502.                 $order->setCountry(null);
  503.             }
  504.         }
  505.         return $this;
  506.     }
  507.     /**
  508.      * @return Collection|PaymentOptions[]
  509.      */
  510.     public function getPaymentOptions(): Collection
  511.     {
  512.         return $this->paymentOptions;
  513.     }
  514.     public function addPaymentOption(PaymentOptions $paymentOption): self
  515.     {
  516.         if (!$this->paymentOptions->contains($paymentOption)) {
  517.             $this->paymentOptions[] = $paymentOption;
  518.             $paymentOption->addCountry($this);
  519.         }
  520.         return $this;
  521.     }
  522.     public function removePaymentOption(PaymentOptions $paymentOption): self
  523.     {
  524.         if ($this->paymentOptions->contains($paymentOption)) {
  525.             $this->paymentOptions->removeElement($paymentOption);
  526.             $paymentOption->removeCountry($this);
  527.         }
  528.         return $this;
  529.     }
  530.     /**
  531.      * @return Collection|ProductVariantPack[]
  532.      */
  533.     public function getProductVariantPacks(): Collection
  534.     {
  535.         return $this->productVariantPacks;
  536.     }
  537.     public function addProductVariantPack(ProductVariantPack $productVariantPack): self
  538.     {
  539.         if (!$this->productVariantPacks->contains($productVariantPack)) {
  540.             $this->productVariantPacks[] = $productVariantPack;
  541.             $productVariantPack->addCountry($this);
  542.         }
  543.         return $this;
  544.     }
  545.     public function removeProductVariantPack(ProductVariantPack $productVariantPack): self
  546.     {
  547.         if ($this->productVariantPacks->contains($productVariantPack)) {
  548.             $this->productVariantPacks->removeElement($productVariantPack);
  549.             $productVariantPack->removeCountry($this);
  550.         }
  551.         return $this;
  552.     }
  553.     /**
  554.      * @return Collection|Address[]
  555.      */
  556.     public function getDeliveryAddressProducts(): Collection
  557.     {
  558.         return $this->deliveryAddressProducts;
  559.     }
  560.     public function addDeliveryAddressProducts(Address $deliveryAddressProduct): self
  561.     {
  562.         if (!$this->deliveryAddressProducts->contains($deliveryAddressProduct)) {
  563.             $this->deliveryAddressProducts[] = $deliveryAddressProduct;
  564.             $address->setCountry($this);
  565.         }
  566.         return $this;
  567.     }
  568.     public function removeDeliveryAddressProducts(Address $deliveryAddressProduct): self
  569.     {
  570.         if ($this->deliveryAddressProducts->contains($deliveryAddressProduct)) {
  571.             $this->deliveryAddressProducts->removeElement($deliveryAddressProduct);
  572.             // set the owning side to null (unless already changed)
  573.             if ($deliveryAddressProduct->getCountry() === $this) {
  574.                 $deliveryAddressProduct->setCountry(null);
  575.             }
  576.         }
  577.         return $this;
  578.     }
  579.     /**
  580.      * @return Collection|Address[]
  581.      */
  582.     public function getAddresses(): Collection
  583.     {
  584.         return $this->addresses;
  585.     }
  586.     public function addAddress(Address $address): self
  587.     {
  588.         if (!$this->addresses->contains($address)) {
  589.             $this->addresses[] = $address;
  590.             $address->setCountry($this);
  591.         }
  592.         return $this;
  593.     }
  594.     public function removeAddress(Address $address): self
  595.     {
  596.         if ($this->addresses->contains($address)) {
  597.             $this->addresses->removeElement($address);
  598.             // set the owning side to null (unless already changed)
  599.             if ($address->getCountry() === $this) {
  600.                 $address->setCountry(null);
  601.             }
  602.         }
  603.         return $this;
  604.     }
  605. }