src/Entity/Cvs/Enterprises.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Cvs;
  3. use App\Entity\Core\Users;
  4. use App\Entity\Core\Agencies;
  5. use Doctrine\DBAL\Types\Types;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\HttpFoundation\File\UploadedFile;
  12. use Vich\UploaderBundle\Entity\File as EmbeddedFile;
  13. use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
  14. /**
  15. * Enterprises
  16. *
  17. * Les index servent les mêmes requêtes que pour les offres : liste triée par
  18. * date, filtres de rattachement, et le `GROUP BY city, country` de l'export.
  19. * Voir `Jobs` pour le détail — et pour la façon de les APPLIQUER, qui n'est
  20. * pas automatique.
  21. *
  22. * @ORM\Table(name="cvs_enterprises", indexes={
  23. * @ORM\Index(name="idx_ent_online_updated", columns={"online", "updated_at"}),
  24. * @ORM\Index(name="idx_ent_city_ref", columns={"city_ref"}),
  25. * @ORM\Index(name="idx_ent_city_slug", columns={"city_slug"}),
  26. * @ORM\Index(name="idx_ent_area", columns={"area_code"}),
  27. * @ORM\Index(name="idx_ent_city_country", columns={"city", "country"})
  28. * })
  29. * @ORM\Entity(repositoryClass="App\Repository\Cvs\EnterprisesRepository")
  30. * @ORM\HasLifecycleCallbacks()
  31. * @Vich\Uploadable
  32. */
  33. class Enterprises
  34. {
  35. /**
  36. * @var integer
  37. *
  38. * @ORM\Column(name="id", type="integer")
  39. * @ORM\Id
  40. * @ORM\GeneratedValue(strategy="AUTO")
  41. */
  42. protected $id;
  43. /**
  44. * @var string
  45. *
  46. * @ORM\Column(name="created_at", type="datetime", nullable=true, options={"comment":"Date de création"})
  47. */
  48. private $createdAt;
  49. /**
  50. * @var string
  51. *
  52. * @ORM\Column(name="updated_at", type="datetime", nullable=true, options={"comment":"Date de mise à jour"})
  53. */
  54. private $updatedAt;
  55. /**
  56. * @var string
  57. *
  58. * @ORM\Column(name="category", type="string", length=255, nullable=true)
  59. */
  60. private $category;
  61. /**
  62. * @var string
  63. *
  64. * @ORM\Column(name="short_title", type="text", nullable=true)
  65. */
  66. private $shortTitle;
  67. /**
  68. * @var string
  69. *
  70. * @ORM\Column(name="short_description", type="text", nullable=true)
  71. */
  72. private $shortDescription;
  73. /**
  74. * @var string
  75. *
  76. * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
  77. */
  78. private $companyName;
  79. /**
  80. * @var string
  81. *
  82. * @ORM\Column(name="address", type="string", length=255, nullable=true)
  83. */
  84. private $address;
  85. /**
  86. * @var string
  87. *
  88. * @ORM\Column(name="city", type="string", length=255, nullable=true)
  89. */
  90. private $city;
  91. /**
  92. * @var string
  93. *
  94. * @ORM\Column(name="zipcode", type="string", length=255, nullable=true)
  95. */
  96. private $zipcode;
  97. /**
  98. * ⚠️ MÊME BESOIN QUE LES OFFRES, MÊME SOLUTION.
  99. *
  100. * `city` est du texte libre. L'annuaire filtre dessus en `LIKE`,
  101. * avec les mêmes défauts : « Paris 15 » ne rejoint pas « Paris ».
  102. *
  103. * La RÉFÉRENCE identifie et survit à un renommage ; le SLUG adresse
  104. * et reste lisible ; `areaCode` se déduit de la ville, ou se choisit
  105. * quand il n'y en a pas.
  106. *
  107. * @var string|null
  108. *
  109. * @ORM\Column(name="city_ref", type="string", length=24, nullable=true)
  110. */
  111. private $cityRef;
  112. /**
  113. * @var string|null
  114. *
  115. * @ORM\Column(name="city_slug", type="string", length=190, nullable=true)
  116. */
  117. private $citySlug;
  118. /**
  119. * @var string|null
  120. *
  121. * @ORM\Column(name="area_code", type="string", length=8, nullable=true)
  122. */
  123. private $areaCode;
  124. /**
  125. * Le secteur d'activité, rattaché au référentiel des métiers.
  126. *
  127. * @var string|null
  128. *
  129. * @ORM\Column(name="trade_ref", type="string", length=24, nullable=true)
  130. */
  131. private $tradeRef;
  132. /**
  133. * @var string
  134. *
  135. * @ORM\Column(name="country", type="string", length=255, nullable=true)
  136. */
  137. private $country;
  138. /**
  139. * @var string
  140. *
  141. * @ORM\Column(name="website", type="string", length=255, nullable=true)
  142. */
  143. private $website;
  144. /**
  145. * @var string
  146. *
  147. * @ORM\Column(name="email", type="string", length=255, nullable=true)
  148. */
  149. private $email;
  150. /**
  151. * Le nombre de candidats intéressés que le recruteur n'a pas encore vus.
  152. *
  153. * ⚠️ UN COMPTEUR, PAS UNE DATE DE DERNIÈRE VISITE.
  154. *
  155. * Comparer `createdAt > lastSeenAt` obligerait à parcourir tous les
  156. * likes à chaque affichage de la coquille — donc sur CHAQUE page.
  157. * Un entier qu'on incrémente à l'écriture et qu'on remet à zéro à
  158. * la lecture coûte une colonne et zéro requête supplémentaire.
  159. *
  160. * @var int|null
  161. *
  162. * @ORM\Column(name="new_interests_count", type="integer", nullable=true, options={"default":0,"comment":"Candidats intéressés non encore consultés"})
  163. */
  164. private $newInterestsCount;
  165. /**
  166. * @var string
  167. *
  168. * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  169. */
  170. private $phone;
  171. /**
  172. * @var string
  173. *
  174. * @ORM\Column(name="company_description", type="text", nullable=true)
  175. */
  176. private $companyDescription;
  177. /**
  178. * @var string
  179. *
  180. * @ORM\Column(name="contact_name", type="string", length=255, nullable=true)
  181. */
  182. private $contactName;
  183. /**
  184. * @var string
  185. *
  186. * @ORM\Column(name="contact_email", type="string", length=255, nullable=true)
  187. */
  188. private $contactEmail;
  189. /**
  190. * @var string
  191. *
  192. * @ORM\Column(name="contact_url", type="string", length=255, nullable=true)
  193. */
  194. private $contactURL;
  195. /**
  196. * NOTE: This is not a mapped field of entity metadata, just a simple property.
  197. *
  198. * @Vich\UploadableField(mapping="enterprises_logo", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName", dimensions="image.dimensions")
  199. *
  200. * @var File|null
  201. */
  202. private $imageFile;
  203. /**
  204. * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File")
  205. *
  206. * @var EmbeddedFile
  207. */
  208. private $image;
  209. /**
  210. * @var string
  211. *
  212. * @ORM\Column(name="online", type="boolean", nullable=true)
  213. */
  214. private $online;
  215. /**
  216. * @var string
  217. *
  218. * @ORM\Column(name="validation", type="boolean", nullable=true)
  219. */
  220. private $validation;
  221. /**
  222. * @var string
  223. *
  224. * @ORM\Column(name="verification", type="boolean", nullable=true)
  225. */
  226. private $verification;
  227. /**
  228. * @var \Users
  229. *
  230. * @ORM\ManyToOne(targetEntity="App\Entity\Core\Users")
  231. * @ORM\JoinColumns({
  232. * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
  233. * })
  234. */
  235. protected $user;
  236. /**
  237. * @var string
  238. *
  239. * @ORM\Column(name="slug", type="string", length=255, nullable=true)
  240. */
  241. private $slug;
  242. /**
  243. * @var string
  244. *
  245. * @ORM\Column(name="locale", type="string", length=255, nullable=true)
  246. */
  247. private $locale;
  248. /**
  249. * @var string
  250. *
  251. * @ORM\Column(name="views", type="integer", length=11, nullable=true)
  252. */
  253. private $views;
  254. /**
  255. * @var string
  256. *
  257. * @ORM\Column(name="pointx", type="string", length=255, nullable=true)
  258. */
  259. private $pointx;
  260. /**
  261. * @var string
  262. *
  263. * @ORM\Column(name="pointy", type="string", length=255, nullable=true)
  264. */
  265. private $pointy;
  266. /**
  267. * @var \Agencies
  268. *
  269. * @ORM\ManyToOne(targetEntity="App\Entity\Core\Agencies")
  270. * @ORM\JoinColumns({
  271. * @ORM\JoinColumn(name="agency_id", referencedColumnName="id", nullable=true)
  272. * })
  273. */
  274. protected $agency;
  275. public function __construct()
  276. {
  277. $this->image = new \Vich\UploaderBundle\Entity\File();
  278. }
  279. /**
  280. * @ORM\PrePersist
  281. */
  282. public function setCreatedAtValue(): void
  283. {
  284. $this->setCreatedAt(new \DateTime("now"));
  285. $this->setUpdatedAt(new \DateTime("now"));
  286. }
  287. /**
  288. * @ORM\PreUpdate
  289. */
  290. public function setUpdatedAtValue(): void
  291. {
  292. $this->setUpdatedAt(new \DateTime("now"));
  293. }
  294. public function __toString()
  295. {
  296. return (string)$this->id;
  297. }
  298. /**
  299. * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  300. * of 'UploadedFile' is injected into this setter to trigger the update. If this
  301. * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  302. * must be able to accept an instance of 'File' as the bundle will inject one here
  303. * during Doctrine hydration.
  304. *
  305. * @param File|UploadedFile|null $imageFile
  306. */
  307. public function setImageFile(?File $imageFile = null)
  308. {
  309. $this->imageFile = $imageFile;
  310. if (null !== $imageFile) {
  311. // It is required that at least one field changes if you are using doctrine
  312. // otherwise the event listeners won't be called and the file is lost
  313. $this->setUpdatedAt(new \DateTime("now"));
  314. }
  315. }
  316. public function getImageFile(): ?File
  317. {
  318. return $this->imageFile;
  319. }
  320. public function setImage(EmbeddedFile $image): void
  321. {
  322. $this->image = $image;
  323. }
  324. public function getImage(): ?EmbeddedFile
  325. {
  326. return $this->image;
  327. }
  328. public function getImageBase64(?string $projectDir = null): ?string
  329. {
  330. if (!$this->image || !$this->image->getName()) {
  331. return null;
  332. }
  333. if (!$projectDir) {
  334. return null; // ou throw new \Exception('Project dir required');
  335. }
  336. $filePath = $projectDir . '/files/cvs/' . $this->image->getName();
  337. if (!file_exists($filePath)) {
  338. return null;
  339. }
  340. $imageData = file_get_contents($filePath);
  341. $mimeType = $this->image->getMimeType() ?? mime_content_type($filePath);
  342. return 'data:' . $mimeType . ';base64,' . base64_encode($imageData);
  343. }
  344. public function getId(): ?int
  345. {
  346. return $this->id;
  347. }
  348. public function getCreatedAt(): ?\DateTimeInterface
  349. {
  350. return $this->createdAt;
  351. }
  352. public function setCreatedAt(?\DateTimeInterface $createdAt): static
  353. {
  354. $this->createdAt = $createdAt;
  355. return $this;
  356. }
  357. public function getUpdatedAt(): ?\DateTimeInterface
  358. {
  359. return $this->updatedAt;
  360. }
  361. public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  362. {
  363. $this->updatedAt = $updatedAt;
  364. return $this;
  365. }
  366. public function getCategory(): ?string
  367. {
  368. return $this->category;
  369. }
  370. public function setCategory(?string $category): static
  371. {
  372. $this->category = $category;
  373. return $this;
  374. }
  375. public function getCompanyName(): ?string
  376. {
  377. return $this->companyName;
  378. }
  379. public function setCompanyName(?string $companyName): static
  380. {
  381. $this->companyName = $companyName;
  382. return $this;
  383. }
  384. public function getAddress(): ?string
  385. {
  386. return $this->address;
  387. }
  388. public function setAddress(?string $address): static
  389. {
  390. $this->address = $address;
  391. return $this;
  392. }
  393. public function getCity(): ?string
  394. {
  395. return $this->city;
  396. }
  397. public function setCity(?string $city): static
  398. {
  399. $this->city = $city;
  400. return $this;
  401. }
  402. public function getZipcode(): ?string
  403. {
  404. return $this->zipcode;
  405. }
  406. public function setZipcode(?string $zipcode): static
  407. {
  408. $this->zipcode = $zipcode;
  409. return $this;
  410. }
  411. public function getCountry(): ?string
  412. {
  413. return $this->country;
  414. }
  415. public function setCountry(?string $country): static
  416. {
  417. $this->country = $country;
  418. return $this;
  419. }
  420. public function getWebsite(): ?string
  421. {
  422. return $this->website;
  423. }
  424. public function setWebsite(?string $website): static
  425. {
  426. $this->website = $website;
  427. return $this;
  428. }
  429. public function getEmail(): ?string
  430. {
  431. return $this->email;
  432. }
  433. public function setEmail(?string $email): static
  434. {
  435. $this->email = $email;
  436. return $this;
  437. }
  438. public function getPhone(): ?string
  439. {
  440. return $this->phone;
  441. }
  442. public function setPhone(?string $phone): static
  443. {
  444. $this->phone = $phone;
  445. return $this;
  446. }
  447. public function getCompanyDescription(): ?string
  448. {
  449. return $this->companyDescription;
  450. }
  451. public function setCompanyDescription(?string $companyDescription): static
  452. {
  453. $this->companyDescription = $companyDescription;
  454. return $this;
  455. }
  456. public function getContactName(): ?string
  457. {
  458. return $this->contactName;
  459. }
  460. public function setContactName(?string $contactName): static
  461. {
  462. $this->contactName = $contactName;
  463. return $this;
  464. }
  465. public function getContactEmail(): ?string
  466. {
  467. return $this->contactEmail;
  468. }
  469. public function setContactEmail(?string $contactEmail): static
  470. {
  471. $this->contactEmail = $contactEmail;
  472. return $this;
  473. }
  474. public function getContactURL(): ?string
  475. {
  476. return $this->contactURL;
  477. }
  478. public function setContactURL(?string $contactURL): static
  479. {
  480. $this->contactURL = $contactURL;
  481. return $this;
  482. }
  483. public function isOnline(): ?bool
  484. {
  485. return $this->online;
  486. }
  487. public function setOnline(?bool $online): static
  488. {
  489. $this->online = $online;
  490. return $this;
  491. }
  492. public function getSlug(): ?string
  493. {
  494. return $this->slug;
  495. }
  496. public function setSlug(?string $slug): static
  497. {
  498. $this->slug = $slug;
  499. return $this;
  500. }
  501. public function getLocale(): ?string
  502. {
  503. return $this->locale;
  504. }
  505. public function setLocale(?string $locale): static
  506. {
  507. $this->locale = $locale;
  508. return $this;
  509. }
  510. public function getNewInterestsCount(): int
  511. {
  512. return (int) $this->newInterestsCount;
  513. }
  514. public function setNewInterestsCount(?int $newInterestsCount): self
  515. {
  516. $this->newInterestsCount = max(0, (int) $newInterestsCount);
  517. return $this;
  518. }
  519. public function getUser(): ?Users
  520. {
  521. return $this->user;
  522. }
  523. public function setUser(?Users $user): static
  524. {
  525. $this->user = $user;
  526. return $this;
  527. }
  528. public function getShortTitle(): ?string
  529. {
  530. return $this->shortTitle;
  531. }
  532. public function setShortTitle(?string $shortTitle): static
  533. {
  534. $this->shortTitle = $shortTitle;
  535. return $this;
  536. }
  537. public function getShortDescription(): ?string
  538. {
  539. return $this->shortDescription;
  540. }
  541. public function setShortDescription(?string $shortDescription): static
  542. {
  543. $this->shortDescription = $shortDescription;
  544. return $this;
  545. }
  546. public function getViews(): ?int
  547. {
  548. return $this->views;
  549. }
  550. public function setViews(?int $views): static
  551. {
  552. $this->views = $views;
  553. return $this;
  554. }
  555. public function isValidation(): ?bool
  556. {
  557. return $this->validation;
  558. }
  559. public function setValidation(?bool $validation): static
  560. {
  561. $this->validation = $validation;
  562. return $this;
  563. }
  564. public function isVerification(): ?bool
  565. {
  566. return $this->verification;
  567. }
  568. public function setVerification(?bool $verification): static
  569. {
  570. $this->verification = $verification;
  571. return $this;
  572. }
  573. public function getPointx(): ?string
  574. {
  575. return $this->pointx;
  576. }
  577. public function setPointx(?string $pointx): static
  578. {
  579. $this->pointx = $pointx;
  580. return $this;
  581. }
  582. public function getPointy(): ?string
  583. {
  584. return $this->pointy;
  585. }
  586. public function setPointy(?string $pointy): static
  587. {
  588. $this->pointy = $pointy;
  589. return $this;
  590. }
  591. public function getAgency(): ?Agencies
  592. {
  593. return $this->agency;
  594. }
  595. public function setAgency(?Agencies $agency): static
  596. {
  597. $this->agency = $agency;
  598. return $this;
  599. }
  600. public function getCityRef(): ?string
  601. {
  602. return $this->cityRef;
  603. }
  604. public function setCityRef(?string $v): self
  605. {
  606. $this->cityRef = $v;
  607. return $this;
  608. }
  609. public function getCitySlug(): ?string
  610. {
  611. return $this->citySlug;
  612. }
  613. public function setCitySlug(?string $v): self
  614. {
  615. $this->citySlug = $v;
  616. return $this;
  617. }
  618. public function getAreaCode(): ?string
  619. {
  620. return $this->areaCode;
  621. }
  622. public function setAreaCode(?string $v): self
  623. {
  624. $this->areaCode = $v;
  625. return $this;
  626. }
  627. public function getTradeRef(): ?string
  628. {
  629. return $this->tradeRef;
  630. }
  631. public function setTradeRef(?string $v): self
  632. {
  633. $this->tradeRef = $v;
  634. return $this;
  635. }
  636. }