src/Entity/Intervention.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InterventionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass="App\Repository\InterventionRepository", repositoryClass=InterventionRepository::class)
  9. */
  10. class Intervention
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private ?int $id;
  18. /**
  19. * @ORM\Column(type="datetime")
  20. */
  21. private ?\DateTimeInterface $createdAt;
  22. /**
  23. * @ORM\Column(type="string", length=255)
  24. */
  25. private ?string $object;
  26. /**
  27. * @ORM\Column(type="boolean")
  28. */
  29. private ?bool $distance;
  30. /**
  31. * @ORM\Column(type="text", nullable=true)
  32. */
  33. private ?string $description;
  34. /**
  35. * @ORM\Column(type="text", nullable=true)
  36. */
  37. private ?string $numFacture;
  38. /**
  39. * @ORM\Column(type="boolean")
  40. */
  41. private ?bool $archived;
  42. /**
  43. * @ORM\ManyToOne(targetEntity=User::class)
  44. * @ORM\JoinColumn(nullable=false)
  45. */
  46. private ?User $creator;
  47. /**
  48. * @ORM\ManyToOne(targetEntity=Customer::class)
  49. * @ORM\JoinColumn(nullable=false)
  50. */
  51. private ?Customer $customer;
  52. /**
  53. * @ORM\ManyToOne(targetEntity=Contact::class)
  54. * @ORM\JoinColumn(nullable=true)
  55. */
  56. private ?Contact $contact;
  57. /**
  58. * @ORM\ManyToMany(targetEntity=TypeIntervention::class)
  59. */
  60. private Collection $typesIntervention;
  61. /**
  62. * @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="interventions", cascade={"persist"}, orphanRemoval="true")
  63. * @ORM\OrderBy({"createdAt" = "ASC"})
  64. */
  65. private $speakers;
  66. /**
  67. * @ORM\ManyToMany(targetEntity=User::class, mappedBy="interventionFav")
  68. */
  69. private $users;
  70. public function __construct()
  71. {
  72. $this->createdAt = new \DateTime(" 00:00:00");
  73. $this->archived = 0;
  74. $this->distance = 0;
  75. $this->typesIntervention = new ArrayCollection();
  76. $this->speakers = new ArrayCollection();
  77. $this->users = new ArrayCollection();
  78. }
  79. // private bool $isFavorite;
  80. //
  81. // /**
  82. // * @return bool
  83. // */
  84. // public function isFavorite(): bool
  85. // {
  86. // return $this->isFavorite;
  87. // }
  88. //
  89. // /**
  90. // * @param bool $isFavorite
  91. // */
  92. // public function setIsFavorite(bool $isFavorite): void
  93. // {
  94. // $this->isFavorite = $isFavorite;
  95. // }
  96. public function getId(): ?int
  97. {
  98. return $this->id;
  99. }
  100. public function getCreatedAt(): ?\DateTimeInterface
  101. {
  102. return $this->createdAt;
  103. }
  104. public function setCreatedAt(\DateTimeInterface $createdAt): self
  105. {
  106. $this->createdAt = $createdAt;
  107. return $this;
  108. }
  109. public function getObject(): ?string
  110. {
  111. return $this->object;
  112. }
  113. public function setObject(string $object): self
  114. {
  115. $this->object = $object;
  116. return $this;
  117. }
  118. public function getDistance(): ?bool
  119. {
  120. return $this->distance;
  121. }
  122. public function setDistance(bool $distance): self
  123. {
  124. $this->distance = $distance;
  125. return $this;
  126. }
  127. public function getDescription(): ?string
  128. {
  129. return $this->description;
  130. }
  131. public function setDescription(string $description): self
  132. {
  133. $this->description = $description;
  134. return $this;
  135. }
  136. public function getNumFacture(): ?string
  137. {
  138. return $this->numFacture;
  139. }
  140. public function setNumFacture(string $numFacture): self
  141. {
  142. $this->numFacture = $numFacture;
  143. return $this;
  144. }
  145. public function getArchived(): ?bool
  146. {
  147. return $this->archived;
  148. }
  149. public function setArchived(bool $archived): self
  150. {
  151. $this->archived = $archived;
  152. return $this;
  153. }
  154. public function getCreator(): ?User
  155. {
  156. return $this->creator;
  157. }
  158. public function setCreator(?User $creator): self
  159. {
  160. $this->creator = $creator;
  161. return $this;
  162. }
  163. public function getCustomer(): ?Customer
  164. {
  165. return $this->customer;
  166. }
  167. public function setCustomer(?Customer $customer): self
  168. {
  169. $this->customer = $customer;
  170. return $this;
  171. }
  172. public function getContact(): ?Contact
  173. {
  174. return $this->contact;
  175. }
  176. public function setContact(?Contact $contact): self
  177. {
  178. $this->contact = $contact;
  179. return $this;
  180. }
  181. /**
  182. * @return Collection|TypeIntervention[]
  183. */
  184. public function getTypesIntervention(): Collection
  185. {
  186. return $this->typesIntervention;
  187. }
  188. public function addTypesIntervention(TypeIntervention $typesIntervention): self
  189. {
  190. if (!$this->typesIntervention->contains($typesIntervention)) {
  191. $this->typesIntervention[] = $typesIntervention;
  192. }
  193. return $this;
  194. }
  195. public function removeTypesIntervention(TypeIntervention $typesIntervention): self
  196. {
  197. $this->typesIntervention->removeElement($typesIntervention);
  198. return $this;
  199. }
  200. /**
  201. * @return Collection<int, Speaker>
  202. */
  203. public function getSpeakers(): Collection
  204. {
  205. return $this->speakers;
  206. }
  207. public function addSpeaker(Speaker $speaker): self
  208. {
  209. if (!$this->speakers->contains($speaker)) {
  210. $this->speakers[] = $speaker;
  211. }
  212. return $this;
  213. }
  214. public function removeSpeaker(Speaker $speaker): self
  215. {
  216. $this->speakers->removeElement($speaker);
  217. return $this;
  218. }
  219. /**
  220. * @return Collection<int, User>
  221. */
  222. public function getUsers(): Collection
  223. {
  224. return $this->users;
  225. }
  226. public function addUser(User $user): self
  227. {
  228. if (!$this->users->contains($user)) {
  229. $this->users[] = $user;
  230. $user->addInterventionFav($this);
  231. }
  232. return $this;
  233. }
  234. public function removeUser(User $user): self
  235. {
  236. if ($this->users->removeElement($user)) {
  237. $user->removeInterventionFav($this);
  238. }
  239. return $this;
  240. }
  241. }