<?php
namespace App\Entity\Gos;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation as JMS;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\CountryRepository")
* @ORM\HasLifecycleCallbacks
*/
class Country
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=true)
* @JMS\Expose()
*/
private $isActive;
/**
* @ORM\Column(type="string", length=255)
* @JMS\Expose()
*/
private $name;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(type="string", length=191, unique=true)
* @JMS\Expose()
*/
private $slug;
/**
* @ORM\Column(type="string", length=3)
* @JMS\Expose()
*/
private $alpha2;
/**
* @ORM\Column(type="string", length=3)
* @JMS\Expose()
*/
private $alpha3;
/**
* @ORM\Column(type="string", length=3, nullable=true)
* @JMS\Expose()
*/
private $ioc;
/**
* @ORM\Column(type="string", length=3, nullable=true)
* @JMS\Expose()
*/
private $emoji;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\Currency", inversedBy="country")
* @ORM\JoinColumn()
*/
private $currency;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\Language", inversedBy="country")
* @ORM\JoinColumn(name="language_id", referencedColumnName="id", onDelete="set null")
*/
private $language;
/**
* @ORM\ManyToOne(targetEntity="Continent", inversedBy="country")
* @ORM\JoinColumn()
*/
private $continent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\User", mappedBy="country")
*/
private $user;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="country")
*/
private $productVariants;
/**
* @ORM\OneToOne(targetEntity="CountrySettings", mappedBy="country")
*/
private $countrySettings;
/**
* @ORM\OneToMany(targetEntity="Cart", mappedBy="country")
*/
private $carts;
/**
* @ORM\OneToMany(targetEntity="Orders", mappedBy="country")
*/
private $orders;
/**
* @ORM\ManyToMany(targetEntity="PaymentOptions", mappedBy="country")
*/
private $paymentOptions;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariantPack", mappedBy="countries")
*/
private $productVariantPacks;
/**
* @ORM\OneToMany(targetEntity=Address::class, mappedBy="deliveryAddressProductCountry")
*/
private $deliveryAddressProducts;
/**
* @ORM\OneToMany(targetEntity=Address::class, mappedBy="country")
*/
private $addresses;
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string)$this->name;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set isActive
*
* @param boolean $isActive
* @return Country
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set name
*
* @param string $name
* @return Country
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
* @return Country
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
* @return Country
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set continent
*
* @param \App\Entity\Gos\Continent $continent
* @return Country
*/
public function setContinent(\App\Entity\Gos\Continent $continent = null)
{
$this->continent = $continent;
return $this;
}
/**
* Get continent
*
* @return \App\Entity\Gos\Continent
*/
public function getContinent()
{
return $this->continent;
}
/**
* Set slug
*
* @param string $slug
* @return Country
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Constructor
*/
public function __construct()
{
$this->user = new \Doctrine\Common\Collections\ArrayCollection();
$this->productVariants = new ArrayCollection();
$this->carts = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->paymentOptions = new ArrayCollection();
$this->productVariantPacks = new ArrayCollection();
$this->addresses = new ArrayCollection();
}
/**
* Add user
*
* @param \App\Entity\Gos\User $user
* @return Country
*/
public function addUser(\App\Entity\Gos\User $user)
{
$this->user[] = $user;
return $this;
}
/**
* Remove user
*
* @param \App\Entity\Gos\User $user
*/
public function removeUser(\App\Entity\Gos\User $user)
{
$this->user->removeElement($user);
}
/**
* Get user
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getUser()
{
return $this->user;
}
/**
* Set alpha2
*
* @param string $alpha2
*
* @return Country
*/
public function setAlpha2($alpha2)
{
$this->alpha2 = $alpha2;
return $this;
}
/**
* Get alpha2
*
* @return string
*/
public function getAlpha2()
{
return $this->alpha2;
}
/**
* Set alpha3
*
* @param string $alpha3
*
* @return Country
*/
public function setAlpha3($alpha3)
{
$this->alpha3 = $alpha3;
return $this;
}
/**
* Get alpha3
*
* @return string
*/
public function getAlpha3()
{
return $this->alpha3;
}
/**
* Set emoji
*
* @param string $emoji
*
* @return Country
*/
public function setEmoji($emoji)
{
$this->emoji = $emoji;
return $this;
}
/**
* Get emoji
*
* @return string
*/
public function getEmoji()
{
return $this->emoji;
}
/**
* Set language
*
* @param \App\Entity\Gos\Language $language
*
* @return Country
*/
public function setLanguage(\App\Entity\Gos\Language $language = null)
{
$this->language = $language;
return $this;
}
/**
* Get language
*
* @return \App\Entity\Gos\Language
*/
public function getLanguage()
{
return $this->language;
}
/**
* Set ioc
*
* @param string $ioc
*
* @return Country
*/
public function setIoc($ioc)
{
$this->ioc = $ioc;
return $this;
}
/**
* Get ioc
*
* @return string
*/
public function getIoc()
{
return $this->ioc;
}
/**
* @return Collection|ProductVariant[]
*/
public function getProductVariants(): Collection
{
return $this->productVariants;
}
public function addProductVariant(ProductVariant $productVariant): self
{
if (!$this->productVariants->contains($productVariant)) {
$this->productVariants[] = $productVariant;
$productVariant->setCountry($this);
}
return $this;
}
public function removeProductVariant(ProductVariant $productVariant): self
{
if ($this->productVariants->contains($productVariant)) {
$this->productVariants->removeElement($productVariant);
// set the owning side to null (unless already changed)
if ($productVariant->getCountry() === $this) {
$productVariant->setCountry(null);
}
}
return $this;
}
public function getCurrency(): ?Currency
{
return $this->currency;
}
public function setCurrency(?Currency $currency): self
{
$this->currency = $currency;
return $this;
}
public function getCountrySettings(): ?CountrySettings
{
return $this->countrySettings;
}
public function setCountrySettings(?CountrySettings $countrySettings): self
{
$this->countrySettings = $countrySettings;
// set (or unset) the owning side of the relation if necessary
$newCountry = $countrySettings === null ? null : $this;
if ($newCountry !== $countrySettings->getCountry()) {
$countrySettings->setCountry($newCountry);
}
return $this;
}
/**
* @return Collection|Cart[]
*/
public function getCarts(): Collection
{
return $this->carts;
}
public function addCart(Cart $cart): self
{
if (!$this->carts->contains($cart)) {
$this->carts[] = $cart;
$cart->setCountry($this);
}
return $this;
}
public function removeCart(Cart $cart): self
{
if ($this->carts->contains($cart)) {
$this->carts->removeElement($cart);
// set the owning side to null (unless already changed)
if ($cart->getCountry() === $this) {
$cart->setCountry(null);
}
}
return $this;
}
/**
* @return Collection|Orders[]
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Orders $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setCountry($this);
}
return $this;
}
public function removeOrder(Orders $order): self
{
if ($this->orders->contains($order)) {
$this->orders->removeElement($order);
// set the owning side to null (unless already changed)
if ($order->getCountry() === $this) {
$order->setCountry(null);
}
}
return $this;
}
/**
* @return Collection|PaymentOptions[]
*/
public function getPaymentOptions(): Collection
{
return $this->paymentOptions;
}
public function addPaymentOption(PaymentOptions $paymentOption): self
{
if (!$this->paymentOptions->contains($paymentOption)) {
$this->paymentOptions[] = $paymentOption;
$paymentOption->addCountry($this);
}
return $this;
}
public function removePaymentOption(PaymentOptions $paymentOption): self
{
if ($this->paymentOptions->contains($paymentOption)) {
$this->paymentOptions->removeElement($paymentOption);
$paymentOption->removeCountry($this);
}
return $this;
}
/**
* @return Collection|ProductVariantPack[]
*/
public function getProductVariantPacks(): Collection
{
return $this->productVariantPacks;
}
public function addProductVariantPack(ProductVariantPack $productVariantPack): self
{
if (!$this->productVariantPacks->contains($productVariantPack)) {
$this->productVariantPacks[] = $productVariantPack;
$productVariantPack->addCountry($this);
}
return $this;
}
public function removeProductVariantPack(ProductVariantPack $productVariantPack): self
{
if ($this->productVariantPacks->contains($productVariantPack)) {
$this->productVariantPacks->removeElement($productVariantPack);
$productVariantPack->removeCountry($this);
}
return $this;
}
/**
* @return Collection|Address[]
*/
public function getDeliveryAddressProducts(): Collection
{
return $this->deliveryAddressProducts;
}
public function addDeliveryAddressProducts(Address $deliveryAddressProduct): self
{
if (!$this->deliveryAddressProducts->contains($deliveryAddressProduct)) {
$this->deliveryAddressProducts[] = $deliveryAddressProduct;
$address->setCountry($this);
}
return $this;
}
public function removeDeliveryAddressProducts(Address $deliveryAddressProduct): self
{
if ($this->deliveryAddressProducts->contains($deliveryAddressProduct)) {
$this->deliveryAddressProducts->removeElement($deliveryAddressProduct);
// set the owning side to null (unless already changed)
if ($deliveryAddressProduct->getCountry() === $this) {
$deliveryAddressProduct->setCountry(null);
}
}
return $this;
}
/**
* @return Collection|Address[]
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
public function addAddress(Address $address): self
{
if (!$this->addresses->contains($address)) {
$this->addresses[] = $address;
$address->setCountry($this);
}
return $this;
}
public function removeAddress(Address $address): self
{
if ($this->addresses->contains($address)) {
$this->addresses->removeElement($address);
// set the owning side to null (unless already changed)
if ($address->getCountry() === $this) {
$address->setCountry(null);
}
}
return $this;
}
}