src/Entity/Payment.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PaymentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use ApiPlatform\Core\Annotation\ApiResource;
  7. /**
  8.  * @ORM\Entity(repositoryClass=PaymentRepository::class)
  9.  */
  10. #[ApiResource()]
  11. class Payment
  12. {
  13.     public function __construct()
  14.     {
  15.         $this->created_at = new \DateTime();
  16.     }
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="integer", options={"default"="0"} )
  25.      */
  26.     private $amount;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $state;
  31.     /**
  32.      * @ORM\Column(type="text", nullable=true)
  33.      */
  34.     private $details;
  35.     /**
  36.      * @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"})
  37.      */
  38.     private $created_at;
  39.     /**
  40.      * @ORM\Column(type="datetime", nullable=true)
  41.      */
  42.     private $updated_at;
  43.     /**
  44.      * @ORM\OneToOne(targetEntity=Order::class, mappedBy="payment", cascade={"persist", "remove"})
  45.      */
  46.     private $order_payment;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=PaymentMethod::class, inversedBy="payment")
  49.      * @ORM\JoinColumn(nullable=false)
  50.      */
  51.     private $paymentMethod;
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getAmount(): ?int
  57.     {
  58.         return $this->amount;
  59.     }
  60.     public function setAmount(int $amount 0): self
  61.     {
  62.         $this->amount $amount;
  63.         return $this;
  64.     }
  65.     public function getState(): ?string
  66.     {
  67.         return $this->state;
  68.     }
  69.     public function setState(string $state ='in progress' ): self
  70.     {
  71.         $this->state $state;
  72.         return $this;
  73.     }
  74.     public function getDetails(): ?string
  75.     {
  76.         return $this->details;
  77.     }
  78.     public function setDetails(?string $details): self
  79.     {
  80.         $this->details $details;
  81.         return $this;
  82.     }
  83.     public function getCreatedAt(): ?\DateTimeInterface
  84.     {
  85.         return $this->created_at;
  86.     }
  87.     public function setCreatedAt(\DateTimeInterface $created_at): self
  88.     {
  89.         $this->created_at $created_at;
  90.         return $this;
  91.     }
  92.     public function getUpdatedAt(): ?\DateTimeInterface
  93.     {
  94.         return $this->updated_at;
  95.     }
  96.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  97.     {
  98.         $this->updated_at $updated_at;
  99.         return $this;
  100.     }
  101.     public function getOrderPayment(): ?Order
  102.     {
  103.         return $this->order_payment;
  104.     }
  105.     public function setOrderPayment(?Order $order_payment): self
  106.     {
  107.         // unset the owning side of the relation if necessary
  108.         if ($order_payment === null && $this->order_payment !== null) {
  109.             $this->order_payment->setPayment(null);
  110.         }
  111.         // set the owning side of the relation if necessary
  112.         if ($order_payment !== null && $order_payment->getPayment() !== $this) {
  113.             $order_payment->setPayment($this);
  114.         }
  115.         $this->order_payment $order_payment;
  116.         return $this;
  117.     }
  118.     public function getPaymentMethod(): ?PaymentMethod
  119.     {
  120.         return $this->paymentMethod;
  121.     }
  122.     public function setPaymentMethod(?PaymentMethod $paymentMethod): self
  123.     {
  124.         $this->paymentMethod $paymentMethod;
  125.         return $this;
  126.     }
  127. }