src/Entity/Gos/Currency.php line 14

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. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\Gos\CurrencyRepository")
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class Currency
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="boolean", nullable=true)
  21.      */
  22.     private $isActive;
  23.     /**
  24.      * @ORM\Column(type="string", length=191)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\Column(type="integer", nullable=true)
  29.      */
  30.     private $decimals;
  31.     /**
  32.      * @Gedmo\Slug(fields={"name"})
  33.      * @ORM\Column(type="string", unique=true, length=191)
  34.      */
  35.     private $slug;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Country", mappedBy="currency")
  38.      */
  39.     private $country;
  40.     /**
  41.      * @ORM\Column(type="text", length=255)
  42.      */
  43.     private $code;
  44.     /**
  45.      * @ORM\Column(type="datetime")
  46.      */
  47.     private $createdAt;
  48.     /**
  49.      * @ORM\Column(type="datetime", nullable=true)
  50.      */
  51.     private $updatedAt;
  52.     public function __construct()
  53.     {
  54.         $this->country = new ArrayCollection();
  55.     }
  56.     /** @ORM\PrePersist() */
  57.     public function prePersist()
  58.     {
  59.         $this->createdAt = new \DateTime();
  60.     }
  61.     /** @ORM\PreUpdate() */
  62.     public function preUpdate()
  63.     {
  64.         $this->updatedAt = new \DateTime();
  65.     }
  66.     public function __toString()
  67.     {
  68.         return (string)$this->name;
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getIsActive(): ?bool
  75.     {
  76.         return $this->isActive;
  77.     }
  78.     public function setIsActive(?bool $isActive): self
  79.     {
  80.         $this->isActive $isActive;
  81.         return $this;
  82.     }
  83.     public function getName(): ?string
  84.     {
  85.         return $this->name;
  86.     }
  87.     public function setName(string $name): self
  88.     {
  89.         $this->name $name;
  90.         return $this;
  91.     }
  92.     public function getDecimals(): ?int
  93.     {
  94.         return $this->decimals;
  95.     }
  96.     public function setDecimals(int $decimals): self
  97.     {
  98.         $this->decimals $decimals;
  99.         return $this;
  100.     }
  101.     public function getCode(): ?string
  102.     {
  103.         return $this->code;
  104.     }
  105.     public function setCode(string $code): self
  106.     {
  107.         $this->code $code;
  108.         return $this;
  109.     }
  110.     public function getSlug(): ?string
  111.     {
  112.         return $this->slug;
  113.     }
  114.     public function setSlug(string $slug): self
  115.     {
  116.         $this->slug $slug;
  117.         return $this;
  118.     }
  119.     public function getCreatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  124.     {
  125.         $this->createdAt $createdAt;
  126.         return $this;
  127.     }
  128.     public function getUpdatedAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->updatedAt;
  131.     }
  132.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  133.     {
  134.         $this->updatedAt $updatedAt;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection|Country[]
  139.      */
  140.     public function getCountry(): Collection
  141.     {
  142.         return $this->country;
  143.     }
  144.     public function addCountry(Country $country): self
  145.     {
  146.         if (!$this->country->contains($country)) {
  147.             $this->country[] = $country;
  148.             $country->setCurrency($this);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeCountry(Country $country): self
  153.     {
  154.         if ($this->country->contains($country)) {
  155.             $this->country->removeElement($country);
  156.             // set the owning side to null (unless already changed)
  157.             if ($country->getCurrency() === $this) {
  158.                 $country->setCurrency(null);
  159.             }
  160.         }
  161.         return $this;
  162.     }
  163. }