src/Entity/PromoPayTransaction.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\CommonTrait;
  4. use App\Repository\PromoPayTransactionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass=PromoPayTransactionRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @UniqueEntity({"uuid"})
  13.  * @ORM\Table(name="promo_pay_transaction")
  14.  */
  15. class PromoPayTransaction
  16. {
  17.     use CommonTrait;
  18.     /**
  19.      * @ORM\ManyToMany(targetEntity=ItemPromotion::class)
  20.      */
  21.     private $promotions;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Item::class, inversedBy="promoPayTransactions")
  24.      * @ORM\JoinColumn(nullable=false)
  25.      */
  26.     private $item;
  27.     /**
  28.      * @ORM\Column(type="decimal", precision=10, scale=0)
  29.      */
  30.     private $ammout;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="promoPayTransactions")
  33.      * @ORM\JoinColumn(nullable=false)
  34.      */
  35.     private $buyer;
  36.     /**
  37.      * @ORM\Column(type="text", nullable=true)
  38.      */
  39.     private $description;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, unique=true)
  42.      */
  43.     private $paymentId;
  44.     /**
  45.      * @ORM\Column(type="string", length=255)
  46.      */
  47.     private $status;
  48.     /**
  49.      * @ORM\Column(type="text")
  50.      */
  51.     private $paymentUrl;
  52.     public function __construct()
  53.     {
  54.         $this->promotions = new ArrayCollection();
  55.     }
  56.     /**
  57.      * @return Collection|ItemPromotion[]
  58.      */
  59.     public function getPromotions(): Collection
  60.     {
  61.         return $this->promotions;
  62.     }
  63.     public function addPromotion(ItemPromotion $promotion): self
  64.     {
  65.         if (!$this->promotions->contains($promotion)) {
  66.             $this->promotions[] = $promotion;
  67.         }
  68.         return $this;
  69.     }
  70.     public function removePromotion(ItemPromotion $promotion): self
  71.     {
  72.         $this->promotions->removeElement($promotion);
  73.         return $this;
  74.     }
  75.     public function getItem(): ?Item
  76.     {
  77.         return $this->item;
  78.     }
  79.     public function setItem(?Item $item): self
  80.     {
  81.         $this->item $item;
  82.         return $this;
  83.     }
  84.     public function getAmmout(): ?string
  85.     {
  86.         return $this->ammout;
  87.     }
  88.     public function setAmmout(string $ammout): self
  89.     {
  90.         $this->ammout $ammout;
  91.         return $this;
  92.     }
  93.     public function getBuyer(): ?User
  94.     {
  95.         return $this->buyer;
  96.     }
  97.     public function setBuyer(?User $buyer): self
  98.     {
  99.         $this->buyer $buyer;
  100.         return $this;
  101.     }
  102.     public function getDescription(): ?string
  103.     {
  104.         return $this->description;
  105.     }
  106.     public function setDescription(?string $description): self
  107.     {
  108.         $this->description $description;
  109.         return $this;
  110.     }
  111.     public function getPaymentId(): ?string
  112.     {
  113.         return $this->paymentId;
  114.     }
  115.     public function setPaymentId(string $paymentId): self
  116.     {
  117.         $this->paymentId $paymentId;
  118.         return $this;
  119.     }
  120.     public function getStatus(): ?string
  121.     {
  122.         return $this->status;
  123.     }
  124.     public function getStatusName()
  125.     {
  126.         switch ($this->getStatus()) {
  127.             case 'NEW':
  128.                 return 'Nowa transakcja';
  129.             case 'CONFIRMED':
  130.                 return 'Transakcja potwierdzona';
  131.             case 'REJECTED':
  132.                 return 'Transakcja odrzucona';
  133.         }
  134.         return '';
  135.     }
  136.     public function setStatus(string $status): self
  137.     {
  138.         $this->status $status;
  139.         return $this;
  140.     }
  141.     public function getIsValid()
  142.     {
  143.         return $this->getStatus() === 'CONFIRMED';
  144.     }
  145.     public function getPaymentUrl(): ?string
  146.     {
  147.         return $this->paymentUrl;
  148.     }
  149.     public function setPaymentUrl(string $paymentUrl): self
  150.     {
  151.         $this->paymentUrl $paymentUrl;
  152.         return $this;
  153.     }
  154. }