src/Entity/Transaction.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TransactionRepository;
  4. use App\Trait\DateTrait;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. #[ORM\Entity(repositoryClass: TransactionRepository::class)]
  8. class Transaction
  9. {
  10.     use DateTrait;
  11.     const STATUS_ERROR = 0;
  12.     const STATUS_SUCCESS = 1;
  13.     const STATUS_PENDING = 3;
  14.     const STATUS_CANCEL = 4;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id = null;
  19.     #[ORM\Column(nullable: true)]
  20.     private ?\DateTimeImmutable $responsedAt = null;
  21.     #[ORM\Column(length: 15)]
  22.     #[Groups('transaction:new')]
  23.     private ?string $phone = null;
  24.     #[ORM\Column(length: 255)]
  25.     private ?string $status = null;
  26.     #[ORM\Column(length: 255)]
  27.     private ?string $operator = null;
  28.     #[ORM\Column]
  29.     private ?float $amount = null;
  30.     #[ORM\Column(length: 255)]
  31.     private ?string $reference = null;
  32.     #[ORM\Column(length: 255, nullable: true)]
  33.     private ?string $providerReference = null;
  34.     #[ORM\Column(length: 255, nullable: true)]
  35.     private ?string $message = null;
  36.     #[ORM\ManyToOne]
  37.     private ?Currency $currency = null;
  38.     #[ORM\OneToOne(inversedBy: 'transaction', cascade: ['persist', 'remove'])]
  39.     private ?Order $orderCommand = null;
  40.     public function __construct()
  41.     {
  42.         if (!$this->createdAt) $this->createdAt = new \DateTimeImmutable();
  43.         $this->updatedAt = new \DateTimeImmutable();
  44.         $this->reference = uniqid();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getResponsedAt(): ?\DateTimeImmutable
  51.     {
  52.         return $this->responsedAt;
  53.     }
  54.     public function setResponsedAt(?\DateTimeImmutable $responsedAt): static
  55.     {
  56.         $this->responsedAt = $responsedAt;
  57.         return $this;
  58.     }
  59.     public function getPhone(): ?string
  60.     {
  61.         return $this->phone;
  62.     }
  63.     public function setPhone(string $phone): static
  64.     {
  65.         $this->phone = $phone;
  66.         return $this;
  67.     }
  68.     public function getStatus(): ?string
  69.     {
  70.         return $this->status;
  71.     }
  72.     public function setStatus(string $status): static
  73.     {
  74.         $this->status = $status;
  75.         return $this;
  76.     }
  77.     public function getOperator(): ?string
  78.     {
  79.         return $this->operator;
  80.     }
  81.     public function setOperator(string $operator): static
  82.     {
  83.         $this->operator = $operator;
  84.         return $this;
  85.     }
  86.     public function getAmount(): ?float
  87.     {
  88.         return $this->amount;
  89.     }
  90.     public function setAmount(float $amount): static
  91.     {
  92.         $this->amount = $amount;
  93.         return $this;
  94.     }
  95.     public function getReference(): ?string
  96.     {
  97.         return $this->reference;
  98.     }
  99.     public function setReference(string $reference): static
  100.     {
  101.         $this->reference = $reference;
  102.         return $this;
  103.     }
  104.     public function getProviderReference(): ?string
  105.     {
  106.         return $this->providerReference;
  107.     }
  108.     public function setProviderReference(?string $providerReference): static
  109.     {
  110.         $this->providerReference = $providerReference;
  111.         return $this;
  112.     }
  113.     public function getMessage(): ?string
  114.     {
  115.         return $this->message;
  116.     }
  117.     public function setMessage(?string $message): static
  118.     {
  119.         $this->message = $message;
  120.         return $this;
  121.     }
  122.     public function getCurrency(): ?Currency
  123.     {
  124.         return $this->currency;
  125.     }
  126.     public function setCurrency(?Currency $currency): static
  127.     {
  128.         $this->currency = $currency;
  129.         return $this;
  130.     }
  131.     public function getOrderCommand(): ?Order
  132.     {
  133.         return $this->orderCommand;
  134.     }
  135.     public function setOrderCommand(?Order $orderCommand): static
  136.     {
  137.         $this->orderCommand = $orderCommand;
  138.         return $this;
  139.     }
  140. }