src/JanusHercules/Jobradar/Domain/Entity/JobradarMatch.php line 29

Open in your IDE?
  1. <?php
  2. namespace JanusHercules\Jobradar\Domain\Entity;
  3. use App\Entity\RecurrentJob;
  4. use App\Entity\WantedJob;
  5. use App\Utility\DatabaseIdGenerator;
  6. use App\Utility\DateTimeUtility;
  7. use DateTime;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping\Column;
  10. use Doctrine\ORM\Mapping\CustomIdGenerator;
  11. use Doctrine\ORM\Mapping\Entity;
  12. use Doctrine\ORM\Mapping\GeneratedValue;
  13. use Doctrine\ORM\Mapping\Id;
  14. use Doctrine\ORM\Mapping\JoinColumn;
  15. use Doctrine\ORM\Mapping\ManyToOne;
  16. use Doctrine\ORM\Mapping\Table;
  17. use Doctrine\ORM\Mapping\UniqueConstraint;
  18. use Exception;
  19. #[Entity]
  20. #[Table(
  21. name : 'jobradar_matches',
  22. uniqueConstraints: [
  23. new UniqueConstraint(name: 'idx_wanted_jobs_id_recurrent_jobs_id', columns: ['wanted_jobs_id', 'recurrent_jobs_id'])
  24. ]
  25. )]
  26. class JobradarMatch
  27. {
  28. #[Id]
  29. #[GeneratedValue(strategy: 'CUSTOM')]
  30. #[CustomIdGenerator(class: DatabaseIdGenerator::class)]
  31. #[Column(
  32. type : Types::GUID,
  33. unique: true
  34. )]
  35. private string $id;
  36. #[Column(
  37. type : Types::DATETIME_MUTABLE,
  38. nullable: false
  39. )]
  40. private DateTime $createdAt;
  41. #[Column(
  42. type : Types::BOOLEAN,
  43. nullable: false
  44. )]
  45. private bool $isPinned = false;
  46. #[Column(
  47. type : Types::BOOLEAN,
  48. nullable: false
  49. )]
  50. private bool $isRead = false;
  51. #[Column(
  52. type : Types::DATETIME_MUTABLE,
  53. nullable: true
  54. )]
  55. private ?DateTime $pinnedAt = null;
  56. #[Column(
  57. type : Types::BOOLEAN,
  58. nullable: false
  59. )]
  60. private bool $isDeleted = false;
  61. #[ManyToOne(
  62. targetEntity: WantedJob::class,
  63. cascade : ['persist']
  64. )]
  65. #[JoinColumn(
  66. name : 'wanted_jobs_id',
  67. referencedColumnName: 'id',
  68. nullable : false,
  69. onDelete : 'CASCADE'
  70. )]
  71. private WantedJob $wantedJob;
  72. #[ManyToOne(
  73. targetEntity: RecurrentJob::class,
  74. cascade : ['persist']
  75. )]
  76. #[JoinColumn(
  77. name : 'recurrent_jobs_id',
  78. referencedColumnName: 'id',
  79. nullable : false,
  80. onDelete : 'CASCADE'
  81. )]
  82. private RecurrentJob $recurrentJob;
  83. /**
  84. * @throws Exception
  85. */
  86. public function __construct(
  87. RecurrentJob $recurrentJob,
  88. WantedJob $wantedJob,
  89. ) {
  90. $this->createdAt = DateTimeUtility::createDateTimeUtc();
  91. $this->recurrentJob = $recurrentJob;
  92. $this->wantedJob = $wantedJob;
  93. }
  94. public function getId(): string
  95. {
  96. return $this->id;
  97. }
  98. public function setId(string $id): void
  99. {
  100. $this->id = $id;
  101. }
  102. public function getCreatedAt(): DateTime
  103. {
  104. return $this->createdAt;
  105. }
  106. public function setCreatedAt(DateTime $createdAt): void
  107. {
  108. $this->createdAt = $createdAt;
  109. }
  110. public function isPinned(): bool
  111. {
  112. return $this->isPinned;
  113. }
  114. public function setIsPinned(bool $isPinned): void
  115. {
  116. $this->isPinned = $isPinned;
  117. }
  118. public function isRead(): bool
  119. {
  120. return $this->isRead;
  121. }
  122. public function setIsRead(bool $isRead): void
  123. {
  124. $this->isRead = $isRead;
  125. }
  126. public function getPinnedAt(): ?DateTime
  127. {
  128. return $this->pinnedAt;
  129. }
  130. public function setPinnedAt(?DateTime $pinnedAt): void
  131. {
  132. $this->pinnedAt = $pinnedAt;
  133. }
  134. public function isDeleted(): bool
  135. {
  136. return $this->isDeleted;
  137. }
  138. public function setIsDeleted(bool $isDeleted): void
  139. {
  140. $this->isDeleted = $isDeleted;
  141. }
  142. public function getWantedJob(): WantedJob
  143. {
  144. return $this->wantedJob;
  145. }
  146. public function getRecurrentJob(): RecurrentJob
  147. {
  148. return $this->recurrentJob;
  149. }
  150. }