src/Entity/Currency.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Base\AbstractTimestampableEntity;
  4. use App\Repository\CurrencyRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CurrencyRepository::class)
  10.  * @ORM\HasLifecycleCallbacks
  11.  */
  12. class Currency extends AbstractTimestampableEntity
  13. {
  14.     const CURRENCY_RON 1;
  15.     const CURRENCY_EUR 2;
  16.     const CURRENCY_HUF 3;
  17.     const CURRENCY_USD 4;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private string $name;
  22.     /**
  23.      * @ORM\Column(type="decimal",  precision=10, scale=6)
  24.      */
  25.     private float $value;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Offer::class, mappedBy="currency")
  28.      */
  29.     private $offers;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=Task::class, mappedBy="currency")
  32.      */
  33.     private $tasks;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=FacturiHeader::class, mappedBy="currency")
  36.      */
  37.     private $facturiHeaders;
  38.     public function __construct()
  39.     {
  40.         $this->offers = new ArrayCollection();
  41.         $this->tasks = new ArrayCollection();
  42.         $this->facturiHeaders = new ArrayCollection();
  43.     }
  44.     public function getName(): string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): void
  49.     {
  50.         $this->name $name;
  51.     }
  52.     public function getValue(): float
  53.     {
  54.         return $this->value;
  55.     }
  56.     public function setValue(float $value): void
  57.     {
  58.         $this->value $value;
  59.     }
  60.     /**
  61.      * @return Collection<int, Offer>
  62.      */
  63.     public function getOffers(): Collection
  64.     {
  65.         return $this->offers;
  66.     }
  67.     public function addOffer(Offer $offer): self
  68.     {
  69.         if (!$this->offers->contains($offer)) {
  70.             $this->offers[] = $offer;
  71.             $offer->setCurrency($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeOffer(Offer $offer): self
  76.     {
  77.         if ($this->offers->removeElement($offer)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($offer->getCurrency() === $this) {
  80.                 $offer->setCurrency(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Task>
  87.      */
  88.     public function getTasks(): Collection
  89.     {
  90.         return $this->tasks;
  91.     }
  92.     public function addTask(Task $task): self
  93.     {
  94.         if (!$this->tasks->contains($task)) {
  95.             $this->tasks[] = $task;
  96.             $task->setCurrency($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeTask(Task $task): self
  101.     {
  102.         if ($this->tasks->removeElement($task)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($task->getCurrency() === $this) {
  105.                 $task->setCurrency(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return Collection<int, FacturiHeader>
  112.      */
  113.     public function getFacturiHeaders(): Collection
  114.     {
  115.         return $this->facturiHeaders;
  116.     }
  117.     public function addFacturiHeader(FacturiHeader $facturiHeader): self
  118.     {
  119.         if (!$this->facturiHeaders->contains($facturiHeader)) {
  120.             $this->facturiHeaders[] = $facturiHeader;
  121.             $facturiHeader->setCurrency($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function removeFacturiHeader(FacturiHeader $facturiHeader): self
  126.     {
  127.         if ($this->facturiHeaders->removeElement($facturiHeader)) {
  128.             // set the owning side to null (unless already changed)
  129.             if ($facturiHeader->getCurrency() === $this) {
  130.                 $facturiHeader->setCurrency(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135. }