src/Entity/PaymentType.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Interfaces\HasCode;
  4. use App\Repository\PaymentTypeRepository;
  5. use App\Utility\Traits\Entity\HasCodeTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ORM\Entity(repositoryClassPaymentTypeRepository::class)]
  11. class PaymentType implements HasCode
  12. {
  13.     use HasCodeTrait;
  14.     public const TYPE_DONATION 'DN';
  15.     public const TYPE_MEMBERSHIP 'MB';
  16.     public const TYPE_PARTY_PILLAR ='PP';
  17.     public const TYPE_RENEW_MEMBERSHIP 'RM';
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(length2)]
  21.     private ?string $paymentTypeCode null;
  22.     #[ORM\Column(length255)]
  23.     private ?string $name null;
  24.     #[ORM\Column]
  25.     private ?int $amount null;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  27.     private ?\DateTimeInterface $updated null;
  28.     #[ORM\OneToMany(mappedBy'paymentType'targetEntityPayment::class)]
  29.     private Collection $payments;
  30.     public function __construct()
  31.     {
  32.         $this->payments = new ArrayCollection();
  33.     }
  34.     public function getPaymentTypeCode(): ?string
  35.     {
  36.         return $this->paymentTypeCode;
  37.     }
  38.     public function setPaymentTypeCode(string $paymentTypeCode): static
  39.     {
  40.         $this->paymentTypeCode $paymentTypeCode;
  41.         return $this;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): static
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function getAmount(): ?int
  53.     {
  54.         return $this->amount;
  55.     }
  56.     public function setAmount(int $amount): static
  57.     {
  58.         $this->amount $amount;
  59.         return $this;
  60.     }
  61.     public function getUpdated(): ?\DateTimeInterface
  62.     {
  63.         return $this->updated;
  64.     }
  65.     #[ORM\PrePersist]
  66.     #[ORM\PreUpdate]
  67.     public function setUpdatedTimestamp(): void
  68.     {
  69.         $this->updated = new \DateTime();
  70.     }
  71.     /**
  72.      * @return Collection<int, Payment>
  73.      */
  74.     public function getPayments(): Collection
  75.     {
  76.         return $this->payments;
  77.     }
  78.     public function addPayment(Payment $payment): static
  79.     {
  80.         if (!$this->payments->contains($payment)) {
  81.             $this->payments->add($payment);
  82.             $payment->setPaymentType($this);
  83.         }
  84.         return $this;
  85.     }
  86.     public function removePayment(Payment $payment): static
  87.     {
  88.         if ($this->payments->removeElement($payment)) {
  89.             // set the owning side to null (unless already changed)
  90.             if ($payment->getPaymentType() === $this) {
  91.                 $payment->setPaymentType(null);
  92.             }
  93.         }
  94.         return $this;
  95.     }
  96. }