src/JanusHercules/SelfServiceTrafficCampaign/Domain/Entity/SelfServiceTrafficCampaignBooking.php line 19

Open in your IDE?
  1. <?php
  2. namespace JanusHercules\SelfServiceTrafficCampaign\Domain\Entity;
  3. use App\Entity\Membership\BillwerkComponentSubscription;
  4. use App\Entity\RecurrentJob;
  5. use App\Utility\DatabaseIdGenerator;
  6. use App\Utility\DateTimeUtility;
  7. use DateTime;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Exception;
  11. use JanusHercules\SelfServiceTrafficCampaign\Domain\Enum\CampaignBookingCreationMode;
  12. use JanusHercules\SelfServiceTrafficCampaign\Domain\Enum\CampaignProduct;
  13. #[ORM\Entity]
  14. #[ORM\Table(name: 'self_service_traffic_campaign_bookings')]
  15. #[ORM\Index(columns: ['created_at'], name: 'created_at_idx')]
  16. class SelfServiceTrafficCampaignBooking
  17. {
  18. /**
  19. * @throws Exception
  20. */
  21. public function __construct()
  22. {
  23. $this->createdAt = DateTimeUtility::createDateTimeUtc();
  24. }
  25. #[ORM\Id]
  26. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  27. #[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
  28. #[ORM\Column(
  29. type : Types::GUID,
  30. unique: true
  31. )]
  32. private ?string $id;
  33. public function getId(): ?string
  34. {
  35. return $this->id;
  36. }
  37. public function setId(?string $id): void
  38. {
  39. $this->id = $id;
  40. }
  41. #[ORM\Column(
  42. type : Types::DATETIME_MUTABLE,
  43. nullable: false
  44. )]
  45. private DateTime $createdAt;
  46. public function setCreatedAt(DateTime $createdAt): void
  47. {
  48. $this->createdAt = $createdAt;
  49. }
  50. public function getCreatedAt(): DateTime
  51. {
  52. return $this->createdAt;
  53. }
  54. #[ORM\ManyToOne(
  55. targetEntity: RecurrentJob::class,
  56. inversedBy: 'selfServiceTrafficCampaignBookings'
  57. )]
  58. #[ORM\JoinColumn(
  59. name: 'recurrent_jobs_id',
  60. referencedColumnName: 'id',
  61. nullable: true,
  62. onDelete: 'SET NULL'
  63. )]
  64. private ?RecurrentJob $recurrentJob;
  65. public function getRecurrentJob(): ?RecurrentJob
  66. {
  67. return $this->recurrentJob;
  68. }
  69. public function setRecurrentJob(?RecurrentJob $recurrentJob): void
  70. {
  71. $this->recurrentJob = $recurrentJob;
  72. }
  73. #[ORM\Column(
  74. type: Types::SMALLINT,
  75. enumType: CampaignBookingCreationMode::class
  76. )]
  77. private CampaignBookingCreationMode $creationMode;
  78. public function getCreationMode(): CampaignBookingCreationMode
  79. {
  80. return $this->creationMode;
  81. }
  82. public function setCreationMode(CampaignBookingCreationMode $mode): void
  83. {
  84. $this->creationMode = $mode;
  85. }
  86. #[ORM\OneToOne(
  87. mappedBy: 'selfServiceTrafficCampaignBooking',
  88. targetEntity: BillwerkComponentSubscription::class,
  89. cascade: ['persist']
  90. )]
  91. private ?BillwerkComponentSubscription $billwerkComponentSubscription = null;
  92. public function getBillwerkComponentSubscription(): ?BillwerkComponentSubscription
  93. {
  94. return $this->billwerkComponentSubscription;
  95. }
  96. public function setBillwerkComponentSubscription(?BillwerkComponentSubscription $billwerkComponentSubscription): void
  97. {
  98. $this->billwerkComponentSubscription = $billwerkComponentSubscription;
  99. }
  100. #[ORM\OneToOne(
  101. mappedBy: 'booking',
  102. targetEntity: SelfServiceTrafficCampaign::class
  103. )]
  104. private ?SelfServiceTrafficCampaign $campaign = null;
  105. public function getCampaign(): ?SelfServiceTrafficCampaign
  106. {
  107. return $this->campaign;
  108. }
  109. public function setCampaign(?SelfServiceTrafficCampaign $campaign): void
  110. {
  111. $this->campaign = $campaign;
  112. }
  113. #[ORM\Column(
  114. type: Types::INTEGER
  115. )]
  116. private int $price;
  117. public function getPrice(): int
  118. {
  119. return $this->price;
  120. }
  121. public function setPrice(int $price): void
  122. {
  123. $this->price = $price;
  124. }
  125. #[ORM\Column(
  126. type: Types::SMALLINT,
  127. nullable: true,
  128. enumType: CampaignProduct::class
  129. )]
  130. private ?CampaignProduct $campaignProduct;
  131. public function getCampaignProduct(): ?CampaignProduct
  132. {
  133. return $this->campaignProduct;
  134. }
  135. public function setCampaignProduct(?CampaignProduct $campaignProduct): void
  136. {
  137. $this->campaignProduct = $campaignProduct;
  138. }
  139. #[ORM\Column(
  140. type: Types::BOOLEAN,
  141. )]
  142. private bool $cancelled = false;
  143. public function isCancelled(): bool
  144. {
  145. return $this->cancelled;
  146. }
  147. public function setCancelled(bool $cancelled): void
  148. {
  149. $this->cancelled = $cancelled;
  150. }
  151. }