src/Entity/UserSubscription.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserSubscriptionRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass=UserSubscriptionRepository::class)
  8. */
  9. class UserSubscription
  10. {
  11. /**
  12. * @ORM\Id
  13. * @ORM\GeneratedValue
  14. * @ORM\Column(type="integer")
  15. */
  16. private ?int $id = NULL;
  17. /**
  18. * Utilisateur rattaché à l'abonnement
  19. *
  20. * @ORM\OneToOne(targetEntity=User::class, mappedBy="subscription")
  21. * @ORM\JoinColumn(nullable=false)
  22. */
  23. private ?User $user = NULL;
  24. /**
  25. * Type d'abonnement rattaché
  26. *
  27. * @ORM\ManyToOne(targetEntity=Subscription::class, inversedBy="userSubscriptions", cascade={"persist"})
  28. * @ORM\JoinColumn(nullable=false)
  29. */
  30. private ?Subscription $subscription = NULL;
  31. /**
  32. * Date de début de l'abonnement
  33. *
  34. * @ORM\Column(type="datetime_immutable")
  35. */
  36. private ?DateTimeImmutable $subscribedAt;
  37. /**
  38. * Date de fin de l'abonnement
  39. *
  40. * @ORM\Column(type="datetime_immutable")
  41. */
  42. private ?DateTimeImmutable $endAt = NULL;
  43. /**
  44. * Nombre fois que l'abonnement a été renouvelé
  45. *
  46. * @ORM\Column(type="integer", options={"default": 0})
  47. */
  48. private int $renewalNumber = 0;
  49. /**
  50. * @ORM\Column(type="datetime_immutable", nullable=true)
  51. */
  52. private ?DateTimeImmutable $renewedAt = NULL;
  53. public function __construct()
  54. {
  55. $this->subscribedAt = new DateTimeImmutable();
  56. }
  57. public function getId(): ?int
  58. {
  59. return $this->id;
  60. }
  61. public function getUser(): ?User
  62. {
  63. return $this->user;
  64. }
  65. public function setUser(User $user): self
  66. {
  67. $this->user = $user;
  68. return $this;
  69. }
  70. public function getSubscription(): ?Subscription
  71. {
  72. return $this->subscription;
  73. }
  74. public function setSubscription(Subscription $subscription): self
  75. {
  76. $this->subscription = $subscription;
  77. return $this;
  78. }
  79. public function getSubscribedAt(): ?DateTimeImmutable
  80. {
  81. return $this->subscribedAt;
  82. }
  83. public function setSubscribedAt(?DateTimeImmutable $subscribedAt): self
  84. {
  85. if ($subscribedAt === NULL) {
  86. $subscribedAt = new DateTimeImmutable();
  87. }
  88. $this->subscribedAt = $subscribedAt;
  89. return $this;
  90. }
  91. public function getEndAt(): ?DateTimeImmutable
  92. {
  93. return $this->endAt;
  94. }
  95. public function setEndAt(DateTimeImmutable $endAt): self
  96. {
  97. $this->endAt = $endAt;
  98. return $this;
  99. }
  100. public function getRenewalNumber(): ?int
  101. {
  102. return $this->renewalNumber;
  103. }
  104. public function setRenewalNumber(int $renewalNumber): self
  105. {
  106. $this->renewalNumber = $renewalNumber;
  107. return $this;
  108. }
  109. public function getRenewedAt(): ?DateTimeImmutable
  110. {
  111. return $this->renewedAt;
  112. }
  113. public function setRenewedAt(?DateTimeImmutable $renewedAt): self
  114. {
  115. $this->renewedAt = $renewedAt;
  116. return $this;
  117. }
  118. }