src/Entity/ServicePro.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ServiceProRepository;
  4. use App\Traits\DateTrait;
  5. use DateTime;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use JMS\Serializer\Annotation as Serializer;
  10. use JMS\Serializer\Annotation\Expose;
  11. use JMS\Serializer\Annotation\Groups;
  12. use Symfony\Component\HttpFoundation\File\File;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. /**
  15. * @ORM\Entity(repositoryClass=ServiceProRepository::class)
  16. *
  17. * @Serializer\ExclusionPolicy("ALL")
  18. *
  19. * @Vich\Uploadable
  20. */
  21. class ServicePro
  22. {
  23. /**
  24. * @ORM\Id
  25. * @ORM\GeneratedValue
  26. * @ORM\Column(type="integer")
  27. *
  28. * @Expose
  29. * @Groups({"service_pro"})
  30. */
  31. private $id;
  32. /**
  33. * @ORM\Column(type="string", length=255)
  34. *
  35. * @Expose
  36. * @Groups({"service_pro"})
  37. */
  38. private $title;
  39. /**
  40. * @ORM\Column(type="text", nullable=true)
  41. */
  42. private $description;
  43. /**
  44. * @ORM\Column(type="string", length=12)
  45. *
  46. * @Expose
  47. * @Groups({"service_pro"})
  48. */
  49. private $value;
  50. /**
  51. * @ORM\Column(type="boolean")
  52. *
  53. * @Expose
  54. * @Groups({"service_pro"})
  55. */
  56. private $status;
  57. use DateTrait;
  58. /**
  59. * @ORM\Column(type="string", length=255, nullable=true)
  60. */
  61. private $image;
  62. // Vich Uploader
  63. /**
  64. * @Vich\UploadableField(mapping="service_pro_images", fileNameProperty="image")
  65. * @var File
  66. */
  67. private $imageFile;
  68. /**
  69. * @ORM\OneToMany(targetEntity=ServiceProField::class, mappedBy="servicePro", orphanRemoval=true, cascade={"persist"})
  70. */
  71. private $serviceProFields;
  72. /**
  73. * @ORM\Column(type="array")
  74. */
  75. private array $contactEmails = [];
  76. public function __construct()
  77. {
  78. $this->serviceProFields = new ArrayCollection();
  79. }
  80. public function getImageFile()
  81. {
  82. return $this->imageFile;
  83. }
  84. /**
  85. * @param File $imageFile
  86. *
  87. * @return void
  88. */
  89. public function setImageFile(File $imageFile): void
  90. {
  91. $this->imageFile = $imageFile;
  92. if (NULL !== $imageFile) {
  93. // It is required that at least one field changes if you are using doctrine
  94. // otherwise the event listeners won't be called and the file is lost
  95. $this->updatedAt = new DateTime();
  96. }
  97. }
  98. public function getImage(): ?string
  99. {
  100. return $this->image;
  101. }
  102. public function setImage(?string $image): self
  103. {
  104. $this->image = $image;
  105. return $this;
  106. }
  107. public function getId(): ?int
  108. {
  109. return $this->id;
  110. }
  111. public function getTitle(): ?string
  112. {
  113. return $this->title;
  114. }
  115. public function setTitle(string $title): self
  116. {
  117. $this->title = $title;
  118. return $this;
  119. }
  120. public function getDescription(): ?string
  121. {
  122. return $this->description;
  123. }
  124. public function setDescription(?string $description): self
  125. {
  126. $this->description = $description;
  127. return $this;
  128. }
  129. public function getValue(): ?string
  130. {
  131. return $this->value;
  132. }
  133. public function setValue(string $value): self
  134. {
  135. $this->value = $value;
  136. return $this;
  137. }
  138. public function isStatus(): ?bool
  139. {
  140. return $this->status;
  141. }
  142. public function setStatus(bool $status): self
  143. {
  144. $this->status = $status;
  145. return $this;
  146. }
  147. /**
  148. * @return Collection<int, ServiceProField>
  149. */
  150. public function getServiceProFields(): Collection
  151. {
  152. return $this->serviceProFields;
  153. }
  154. public function addServiceProField(ServiceProField $serviceProField): self
  155. {
  156. if (!$this->serviceProFields->contains($serviceProField)) {
  157. $this->serviceProFields[] = $serviceProField;
  158. $serviceProField->setServicePro($this);
  159. }
  160. return $this;
  161. }
  162. public function removeServiceProField(ServiceProField $serviceProField): self
  163. {
  164. if ($this->serviceProFields->removeElement($serviceProField)) {
  165. // set the owning side to null (unless already changed)
  166. if ($serviceProField->getServicePro() === $this) {
  167. $serviceProField->setServicePro(NULL);
  168. }
  169. }
  170. return $this;
  171. }
  172. public function getContactEmails(): ?array
  173. {
  174. return $this->contactEmails;
  175. }
  176. public function setContactEmails(array $contactEmails): self
  177. {
  178. $this->contactEmails = $contactEmails;
  179. return $this;
  180. }
  181. }