src/Entity/Payment.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6.  * @ORM\Entity(repositoryClass=PaymentRepository::class)
  7.  * @ORM\Table(name="payment")
  8.  */
  9. class Payment
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private ?int $id null;
  17.     /**
  18.      * @ORM\Column(type="integer")
  19.      * @Assert\Positive(message="The amount must be positive.")
  20.      */
  21.     private int $amount;
  22.     /**
  23.      * @ORM\Column(type="string", length=3)
  24.      * @Assert\Length(
  25.      *     min=3,
  26.      *     max=3,
  27.      *     exactMessage="Currency must be a 3-letter ISO code."
  28.      * )
  29.      */
  30.     private string $currency;
  31.     /**
  32.      * @ORM\Column(type="string", length=50)
  33.      * @Assert\NotBlank()
  34.      */
  35.     private string $status;
  36.     /**
  37.      * @ORM\Column(type="datetime")
  38.      */
  39.     private \DateTimeInterface $createdAt;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=Booking::class, inversedBy="payments")
  42.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  43.      */
  44.     private Booking $booking;
  45.     public function __construct(Booking $booking)
  46.     {
  47.         $this->booking   $booking;
  48.         $this->createdAt = new \DateTimeImmutable('now');
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getAmount(): int
  55.     {
  56.         return $this->amount;
  57.     }
  58.     public function setAmount(int $amount): self
  59.     {
  60.         $this->amount $amount;
  61.         return $this;
  62.     }
  63.     public function getCurrency(): string
  64.     {
  65.         return $this->currency;
  66.     }
  67.     public function setCurrency(string $currency): self
  68.     {
  69.         $this->currency $currency;
  70.         return $this;
  71.     }
  72.     public function getStatus(): string
  73.     {
  74.         return $this->status;
  75.     }
  76.     public function setStatus(string $status): self
  77.     {
  78.         $this->status $status;
  79.         return $this;
  80.     }
  81.     public function getCreatedAt(): \DateTimeInterface
  82.     {
  83.         return $this->createdAt;
  84.     }
  85.     public function getBooking(): Booking
  86.     {
  87.         return $this->booking;
  88.     }
  89.     public function setBooking(Booking $booking): self
  90.     {
  91.         $this->booking $booking;
  92.         return $this;
  93.     }
  94. }