src/Entity/GiftVoucher.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GiftVoucherRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassGiftVoucherRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class GiftVoucher extends BaseEntity
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255uniquetrue)]
  17.     private ?string $code null;
  18.     #[ORM\Column(typeTypes::DECIMALprecision19scale4)]
  19.     private ?string $initialAmount null;
  20.     #[ORM\Column(typeTypes::DECIMALprecision19scale4)]
  21.     private ?string $balance null;
  22.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  23.     private ?\DateTimeInterface $expiryDate null;
  24.     #[ORM\Column(length50)]
  25.     private ?string $status 'ACTIVE'// ACTIVE, DEPLETED, EXPIRED, CANCELLED
  26.     #[ORM\ManyToOne(inversedBy'giftVouchers')]
  27.     private ?Customer $customer null;
  28.     #[ORM\OneToMany(mappedBy'voucher'targetEntityGiftVoucherUsage::class)]
  29.     private Collection $usages;
  30.     public function __construct()
  31.     {
  32.         $this->usages = new ArrayCollection();
  33.         $this->createdAt = new \DateTimeImmutable();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getCode(): ?string
  40.     {
  41.         return $this->code;
  42.     }
  43.     public function setCode(string $code): static
  44.     {
  45.         $this->code $code;
  46.         return $this;
  47.     }
  48.     public function getInitialAmount(): ?string
  49.     {
  50.         return $this->initialAmount;
  51.     }
  52.     public function setInitialAmount(string $initialAmount): static
  53.     {
  54.         $this->initialAmount $initialAmount;
  55.         return $this;
  56.     }
  57.     public function getBalance(): ?string
  58.     {
  59.         return $this->balance;
  60.     }
  61.     public function setBalance(string $balance): static
  62.     {
  63.         $this->balance $balance;
  64.         return $this;
  65.     }
  66.     public function getExpiryDate(): ?\DateTimeInterface
  67.     {
  68.         return $this->expiryDate;
  69.     }
  70.     public function setExpiryDate(\DateTimeInterface $expiryDate): static
  71.     {
  72.         $this->expiryDate $expiryDate;
  73.         return $this;
  74.     }
  75.     public function getStatus(): ?string
  76.     {
  77.         return $this->status;
  78.     }
  79.     public function setStatus(string $status): static
  80.     {
  81.         $this->status $status;
  82.         return $this;
  83.     }
  84.     public function getCustomer(): ?Customer
  85.     {
  86.         return $this->customer;
  87.     }
  88.     public function setCustomer(?Customer $customer): static
  89.     {
  90.         $this->customer $customer;
  91.         return $this;
  92.     }
  93.     /**
  94.      * @return Collection<int, GiftVoucherUsage>
  95.      */
  96.     public function getUsages(): Collection
  97.     {
  98.         return $this->usages;
  99.     }
  100.     public function addUsage(GiftVoucherUsage $usage): static
  101.     {
  102.         if (!$this->usages->contains($usage)) {
  103.             $this->usages->add($usage);
  104.             $usage->setVoucher($this);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeUsage(GiftVoucherUsage $usage): static
  109.     {
  110.         if ($this->usages->removeElement($usage)) {
  111.             // set the owning side to null (unless already changed)
  112.             if ($usage->getVoucher() === $this) {
  113.                 $usage->setVoucher(null);
  114.             }
  115.         }
  116.         return $this;
  117.     }
  118. }