src/Entity/JobOffer.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\JobOfferRepository;
  4. use App\Tools\Utils;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use UploadBundle\Annotation\Uploadable;
  8. use UploadBundle\Annotation\UploadableField;
  9. #[ORM\Table(name'job_offer')]
  10. #[ORM\Entity(repositoryClassJobOfferRepository::class)]
  11. #[Uploadable]
  12. class JobOffer {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private ?int $id null;
  17.     #[ORM\Column(name'title'type'string'length255)]
  18.     #[Assert\NotBlank]
  19.     private ?string $title;
  20.     #[ORM\Column(name'description'type'text'nullabletrue)]
  21.     #[Assert\Length(min'20'max2000)]
  22.     private ?string $description;
  23.     #[ORM\Column(name'created_date'type'datetime'nullabletrue)]
  24.     private ?\DateTime $createdDate null;
  25.     #[ORM\Column(name'closed_date'type'datetime'nullabletrue)]
  26.     private ?\DateTime $closedDate null;
  27.     #[ORM\Column(name'posted_contact'type'string'length255nullabletrue)]
  28.     private ?string $postedContact;
  29.     #[ORM\Column(name'posted_phone'type'string'length255nullabletrue)]
  30.     private ?string $postedPhone;
  31.     #[ORM\Column(name'posted_email'type'string'length255)]
  32.     #[Assert\Email]
  33.     private ?string $postedEmail;
  34.     #[ORM\Column(name'cover_letter'type'string'nullabletrue)]
  35.     private ?string $coverLetter;
  36.     #[ORM\Column(name'other_activity'type'string'length255nullabletrue)]
  37.     private ?string $otherActivity;
  38.     #[ORM\Column(name'filename'type'string'length255nullabletrue)]
  39.     private ?string $filename null;
  40.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'jobOffers')]
  41.     #[ORM\JoinColumn(name'id_company'referencedColumnName'id')]
  42.     private ?Company $company null;
  43.     #[ORM\ManyToOne(targetEntitySchool::class, inversedBy'jobOffers')]
  44.     #[ORM\JoinColumn(name'id_school'referencedColumnName'id')]
  45.     private ?School $school null;
  46.     #[ORM\ManyToOne(targetEntitySectorArea::class)]
  47.     #[ORM\JoinColumn(name'id_sectorArea'referencedColumnName'id')]
  48.     private ?SectorArea $sectorArea null;
  49.     #[ORM\ManyToOne(targetEntityActivity::class)]
  50.     #[ORM\JoinColumn(nullabletrue)]
  51.     private ?Activity $activity null;
  52.     #[ORM\ManyToOne(targetEntityContract::class)]
  53.     #[ORM\JoinColumn(name'lasted_contract_id'referencedColumnName'id'nullabletrue)]
  54.     private ?Contract $contract null;
  55.     #[ORM\ManyToOne(targetEntityCity::class, inversedBy'jobOffers')]
  56.     #[ORM\JoinColumn(name'id_city'referencedColumnName'id')]
  57.     private ?City $city null;
  58.     #[ORM\Column(name'other_city'type'string'length255nullabletrue)]
  59.     private ?string $otherCity;
  60.     #[ORM\ManyToOne(targetEntityRegion::class)]
  61.     #[ORM\JoinColumn(name'id_region'referencedColumnName'id')]
  62.     private ?Region $region null;
  63.     #[ORM\ManyToOne(targetEntityCountry::class)]
  64.     #[ORM\JoinColumn(name'id_country'referencedColumnName'id')]
  65.     private ?Country $country null;
  66.     #[ORM\Column(name'updated_date'type'datetime'nullabletrue)]
  67.     private ?\DateTime $updatedDate;
  68.     #[ORM\Column(name'is_view'type'boolean')]
  69.     private bool $isView false;
  70.     #[ORM\Column(name'candidate_profile'type'text'nullabletrue)]
  71.     #[Assert\Length(min'20'max2000)]
  72.     private ?string $candidateProfile;
  73.     #[ORM\Column(name'candidate_sended'type'text'nullabletrue)]
  74.     private ?string $candidateSended ;
  75.     public function __construct() {
  76.         $this->createdDate = new \DateTime();
  77.         $this->updatedDate = new \DateTime();
  78.         // Closed after 3 months
  79.         $this->closedDate = (new \DateTime())->add(new \DateInterval('P3M'));;
  80.     }
  81.     public function getId(): ?int {
  82.         return $this->id;
  83.     }
  84.     public function getTitle(): ?string {
  85.         return $this->title;
  86.     }
  87.     public function setTitle(?string $title): self {
  88.         $this->title $title;
  89.         return $this;
  90.     }
  91.     public function getCreatedDate(): ?\DateTime {
  92.         return $this->createdDate;
  93.     }
  94.     public function setCreatedDate(?\DateTime $createdDate): self {
  95.         $this->createdDate $createdDate;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return string|null
  100.      */
  101.     public function getClosedDate(): ?string {
  102.         return ($this->closedDate) ? $this->closedDate->format(Utils::FORMAT_FR) : null;
  103.     }
  104.     public function setClosedDate(?string $closedDate): self {
  105.         if ($closedDate) {
  106.             $this->closedDate \DateTime::createFromFormat(Utils::FORMAT_FR$closedDate);
  107.         }
  108.         return $this;
  109.     }
  110.     public function getCompany(): ?Company {
  111.         return $this->company;
  112.     }
  113.     public function setCompany(?Company $company null): self {
  114.         $this->company $company;
  115.         return $this;
  116.     }
  117.     public function getSchool(): ?School {
  118.         return $this->school;
  119.     }
  120.     public function setSchool(?School $school null): self {
  121.         $this->school $school;
  122.         return $this;
  123.     }
  124.     public function getDescription(): ?string {
  125.         return $this->description;
  126.     }
  127.     public function setDescription(?string $description): self {
  128.         $this->description $description;
  129.         return $this;
  130.     }
  131.     public function getPostedEmail(): ?string {
  132.         return $this->postedEmail;
  133.     }
  134.     public function setPostedEmail(?string $postedEmail): self {
  135.         $this->postedEmail $postedEmail;
  136.         return $this;
  137.     }
  138.     public function getPostedContact(): ?string {
  139.         return $this->postedContact;
  140.     }
  141.     public function setPostedContact(?string $postedContact): self {
  142.         $this->postedContact $postedContact;
  143.         return $this;
  144.     }
  145.     public function getPostedPhone(): ?string {
  146.         return $this->postedPhone;
  147.     }
  148.     public function setPostedPhone(?string $postedPhone): self {
  149.         $this->postedPhone $postedPhone;
  150.         return $this;
  151.     }
  152.     public function getCoverLetter(): ?string {
  153.         return $this->coverLetter;
  154.     }
  155.     public function setCoverLetter(?string $coverLetter): self {
  156.         $this->coverLetter $coverLetter;
  157.         return $this;
  158.     }
  159.     public function getSectorArea(): ?SectorArea {
  160.         return $this->sectorArea;
  161.     }
  162.     public function setSectorArea(?SectorArea $sectorArea): self {
  163.         $this->sectorArea $sectorArea;
  164.         return $this;
  165.     }
  166.     public function getActivity(): ?Activity {
  167.         return $this->activity;
  168.     }
  169.     public function setActivity(?Activity $activity): self {
  170.         $this->activity $activity;
  171.         return $this;
  172.     }
  173.     public function getOtherActivity(): ?string {
  174.         return $this->otherActivity;
  175.     }
  176.     public function setOtherActivity(?string $otherActivity): self {
  177.         $this->otherActivity $otherActivity;
  178.         return $this;
  179.     }
  180.     public function getContract(): ?Contract {
  181.         return $this->contract;
  182.     }
  183.     public function setContract(?Contract $contract): self {
  184.         $this->contract $contract;
  185.         return $this;
  186.     }
  187.     public function getOtherCity(): ?string {
  188.         return $this->otherCity;
  189.     }
  190.     public function setOtherCity(?string $otherCity): self {
  191.         $this->otherCity $otherCity;
  192.         return $this;
  193.     }
  194.     public function getCity(): ?City {
  195.         return $this->city;
  196.     }
  197.     public function setCity(?City $city): self {
  198.         $this->city $city;
  199.         return $this;
  200.     }
  201.     public function getRegion(): ?Region {
  202.         return $this->region;
  203.     }
  204.     public function setRegion(?Region $region): self {
  205.         $this->region $region;
  206.         return $this;
  207.     }
  208.     public function getCountry(): ?Country {
  209.         return $this->country;
  210.     }
  211.     public function setCountry(?Country $country): self {
  212.         $this->country $country;
  213.         return $this;
  214.     }
  215.     /**
  216.      * @return Prefecture|null
  217.      */
  218.     public function getPrefecture(): ?Prefecture {
  219.         return $this->city?->getPrefecture();
  220.     }
  221.     /**
  222.      * @param Prefecture|null $prefecture
  223.      * @return JobOffer
  224.      */
  225.     public function setPrefecture(?Prefecture $prefecture): JobOffer
  226.     {
  227.         return $this;
  228.     }
  229.     public function setFilename(?string $filename): self {
  230.         $this->filename $filename;
  231.         return $this;
  232.     }
  233.     public function getFilename(): ?string {
  234.         return $this->filename;
  235.     }
  236.     public function getUpdatedDate(): ?\DateTime {
  237.         return $this->updatedDate ?: $this->createdDate;
  238.     }
  239.     public function setUpdatedDate(?\DateTime $updatedDate): self {
  240.         $this->updatedDate $updatedDate;
  241.         return $this;
  242.     }
  243.     public function getCandidateProfile(): ?string {
  244.         return $this->candidateProfile;
  245.     }
  246.     public function setCandidateProfile(?string $candidateProfile): self {
  247.         $this->candidateProfile $candidateProfile;
  248.         return $this;
  249.     }
  250.     public function isView(): bool {
  251.         return $this->isView;
  252.     }
  253.     public function setIsView(bool $isView): self {
  254.         $this->isView $isView;
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return ?string
  259.      */
  260.     public function getCandidateSended(): ?string
  261.     {
  262.         return $this->candidateSended;
  263.     }
  264.     /**
  265.      * @param ?string $candidateSended
  266.      */
  267.     public function setCandidateSended(?string $candidateSended): void
  268.     {
  269.         $this->candidateSended $candidateSended;
  270.     }
  271.     /**
  272.      * @param int $candidateSendedId
  273.      */
  274.     public function addCandidateSended(int $candidateSendedId): void
  275.     {
  276.         if(!$this->candidateSended) {
  277.             $this->candidateSended $candidateSendedId;
  278.         } else if (!in_array($candidateSendedIdexplode(','$this->candidateSended))) {
  279.             $this->candidateSended .=  ',' .  $candidateSendedId ;
  280.         }
  281.     }
  282.     public  function isCandidateSended(int $candidateSendedId): bool
  283.     {
  284.         return in_array($candidateSendedIdexplode($this->candidateSended','));
  285.     }
  286.     public function getLogo() {
  287.         $company $this->getCompany();
  288.         $school $this->getSchool();
  289.         if ($company && $company->getUser()->getImageName()) {
  290.             $logo $company->getUser()->getImageName();
  291.         } else if ($school && $school->getUser()->getImageName()) {
  292.             $logo $school->getUser()->getImageName();
  293.         } else {
  294.             $logo false;
  295.         }
  296.         return $logo;
  297.     }
  298. }