src/Entity/Specialist.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Address;
  4. use App\Repository\SpecialistRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. /**
  15.  * @ORM\Entity(repositoryClass=SpecialistRepository::class)
  16.  * @Vich\Uploadable
  17.  * @ORM\HasLifecycleCallbacks()
  18.  */
  19. class Specialist
  20. {
  21.     const STATUS_WAITING_MAIL_CONFIRMATION 'waiting_mail_confirmation'// specialist has been created but must confirm by clicking on link in email
  22.     const STATUS_WAITING_ULTEAM_CONFIRMATION 'waiting_ulteam_confirmation'// specialist has validated mail but is waiting for ULTEAM to confirm registration
  23.     const STATUS_REFUSED 'refused'// specialist registration has been refused by ULTEAM
  24.     const STATUS_GRANTED 'granted'// specialist has been granted full access to his back office by ULTEAM
  25.     
  26.     /**
  27.      * Available statuses for the specialist
  28.      */
  29.     const STATUSES = [
  30.         self::STATUS_WAITING_MAIL_CONFIRMATION,
  31.         self::STATUS_WAITING_ULTEAM_CONFIRMATION,
  32.         self::STATUS_REFUSED,
  33.         self::STATUS_GRANTED,
  34.     ];
  35.     /**
  36.      * Available types for the specialist
  37.      */
  38.     const TYPES = [
  39.         100 => 'Indépendant',
  40.         200 => 'Affilié',
  41.         300 => '100% Affilié'
  42.     ];
  43.     use Address;
  44.     /**
  45.      * @ORM\Id
  46.      * @ORM\GeneratedValue
  47.      * @ORM\Column(type="integer")
  48.      * @Groups({"search", "event:read"})
  49.      */
  50.     private $id;
  51.     /**
  52.      * @ORM\Column(type="string", length=255)
  53.      * @Groups({"event:read"})
  54.      * @Assert\NotBlank
  55.      */
  56.     private $firstName;
  57.     /**
  58.      * @ORM\Column(type="string", length=255)
  59.      * @Groups({"event:read"})
  60.      * @Assert\NotBlank
  61.      */
  62.     private $lastName;
  63.     /**
  64.      * @ORM\Column(type="datetime")
  65.      * @Gedmo\Timestampable(on="create")
  66.      * @var \DateTime
  67.      */
  68.     private $createdAt;
  69.     /**
  70.      * @ORM\Column(type="string", length=255, nullable=true)
  71.      * @Groups({"event:read"})
  72.      */
  73.     private $image;
  74.     /**
  75.      * @Groups({"specialist:read", "specialist:read:imageUrl", "event:read"})
  76.      * @var ?string
  77.      */
  78.     private $imageUrl "https://placehold.co/600x300";
  79.     /**
  80.      * @Vich\UploadableField(mapping="specialists_images", fileNameProperty="image")
  81.      * @Assert\File(
  82.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  83.      *     maxSize="700Ki",
  84.      * )
  85.      * @var File|null
  86.      */
  87.     private $imageFile;
  88.     /**
  89.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="specialist", cascade={"persist", "remove"})
  90.      * @ORM\JoinColumn(nullable=false)
  91.      * @Assert\Valid
  92.      */
  93.     private $user;
  94.     /**
  95.      * @ORM\Column(type="datetime", nullable=true)
  96.      * @Gedmo\Timestampable(on="update")
  97.      */
  98.     private $updatedAt;
  99.     /**
  100.      * @ORM\OneToMany(targetEntity=SpecialistTag::class, mappedBy="specialist", cascade={"all"})
  101.      * @Groups({"event:read"})
  102.      */
  103.     private $specialistTags;
  104.     /**
  105.      * @ORM\OneToMany(targetEntity=Event::class, mappedBy="specialist")
  106.      */
  107.     private $events;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=SpecialistEventApplication::class, mappedBy="specialist", orphanRemoval=true)
  110.      */
  111.     private $applications;
  112.     /**
  113.      * Search radius in meters
  114.      * @ORM\Column(type="float")
  115.      */
  116.     private $radius 5;
  117.     /**
  118.      * @ORM\OneToMany(targetEntity=Workshop::class, mappedBy="specialist")
  119.      */
  120.     private $workshops;
  121.     /**
  122.      * @ORM\Column(type="text", nullable=true)
  123.      * @Groups({"event:read"})
  124.      */
  125.     private $description;
  126.     /**
  127.      * @ORM\Column(type="string", length=255, nullable=true)
  128.      * @Assert\Length(max="12", maxMessage="Numéro de téléphone invalide",
  129.      * min="10", minMessage="Numéro de téléphone invalide")
  130.      */
  131.     private $tel;
  132.     /**
  133.      * @ORM\OneToMany(targetEntity=InvoiceApplication::class, mappedBy="specialist")
  134.      */
  135.     private $invoiceApplications;
  136.     /**
  137.      * @ORM\Column(type="boolean", options={"default": 1})
  138.      */
  139.     private $isTva true;
  140.     /**
  141.      * @ORM\OneToMany(targetEntity=VisioEvent::class, mappedBy="specialist", orphanRemoval=true)
  142.      */
  143.     private $visioEvents;
  144.     /**
  145.      * @ORM\ManyToMany(targetEntity=VisioEventPromotion::class, mappedBy="specialists")
  146.      */
  147.     private $visioEventPromotions;
  148.     /**
  149.      * @ORM\Column(type="string", length=255, nullable=true)
  150.      */
  151.     private $status;
  152.     /**
  153.      * @ORM\Column(type="datetime", nullable=true)
  154.      * @Gedmo\Timestampable(on="update", field={"status"})
  155.      */
  156.     private $statusDate;
  157.     /**
  158.      * @ORM\Column(type="text", nullable=true)
  159.      */
  160.     private $statusMessage;
  161.     /**
  162.      * @ORM\Column(type="string", length=255, nullable=true)
  163.      */
  164.     private $identityCard;
  165.     /**
  166.      * @Vich\UploadableField(mapping="specialists_documents", fileNameProperty="identityCard")
  167.      * @Assert\File(
  168.      *     mimeTypes={"application/pdf"},
  169.      *     maxSize="2M",
  170.      * )
  171.      * @var File|null
  172.      */
  173.     private $identityCardFile;
  174.     /**
  175.      * @ORM\Column(type="string", length=255, nullable=true)
  176.      */
  177.     private $insurance;
  178.     /**
  179.      * @Vich\UploadableField(mapping="specialists_documents", fileNameProperty="insurance")
  180.      * @Assert\File(
  181.      *     mimeTypes={"application/pdf"},
  182.      *     maxSize="2M",
  183.      * )
  184.      * @var File|null
  185.      */
  186.     private $insuranceFile;
  187.     /**
  188.      * @ORM\Column(type="string", length=255, nullable=true)
  189.      */
  190.     private $degree;
  191.     /**
  192.      * @Vich\UploadableField(mapping="specialists_documents", fileNameProperty="degree")
  193.      * @Assert\File(
  194.      *     mimeTypes={"application/pdf"},
  195.      *     maxSize="2M",
  196.      * )
  197.      * @var File|null
  198.      */
  199.     private $degreeFile;
  200.     /**
  201.      * @ORM\Column(type="string", length=255, nullable=true)
  202.      */
  203.     private $rib;
  204.     /**
  205.      * @Vich\UploadableField(mapping="specialists_documents", fileNameProperty="rib")
  206.      * @Assert\File(
  207.      *     mimeTypes={"application/pdf"},
  208.      *     maxSize="2M",
  209.      * )
  210.      * @var File|null
  211.      */
  212.     private $ribFile;
  213.     /**
  214.      * @ORM\Column(type="boolean", options={"default": 1})
  215.      */
  216.     private $isVirtualEvent true;
  217.     /**
  218.      * @ORM\Column(type="uuid", nullable=true)
  219.      */
  220.     private $uuid;
  221.     /**
  222.      * @ORM\Column(type="boolean", nullable=true, options={"default": "0"})
  223.      */
  224.     private $isAffiliated false;
  225.     /**
  226.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="affiliatedSpecialists")
  227.      */
  228.     private $affiliatedCompany;
  229.     /**
  230.      * @ORM\ManyToMany(targetEntity=Company::class, inversedBy="specialists")
  231.      */
  232.     private $companies;
  233.     
  234.     private $specialistType;
  235.     /**
  236.      * @ORM\OneToMany(targetEntity=AffiliatedEventApplication::class, mappedBy="specialist", orphanRemoval=true)
  237.      */
  238.     private $affiliatedEventApplications;
  239.     /**
  240.      * @ORM\Column(type="string", length=255, nullable=true)
  241.      */
  242.     private $siret;
  243.    
  244.     /**
  245.      * @ORM\OneToMany(targetEntity=CancelEventApplication::class, mappedBy="specialist", orphanRemoval=true)
  246.      */
  247.     private $cancelEventApplications;
  248.     /**
  249.      * Custom field
  250.      * @Groups({"event:read"})
  251.      */
  252.     private $tags null;
  253.     /**
  254.      * @ORM\Column(type="boolean", options={"default": 0})
  255.      */
  256.     private $fiveKWarningSent true;
  257.     public function __construct()
  258.     {
  259.         $this->createdAt = new \DateTime();
  260.         $this->specialistTags = new ArrayCollection();
  261.         $this->events = new ArrayCollection();
  262.         $this->applications = new ArrayCollection();
  263.         $this->user = new User();
  264.         $this->workshops = new ArrayCollection();
  265.         $this->invoiceApplications = new ArrayCollection();
  266.         $this->visioEvents = new ArrayCollection();
  267.         $this->visioEventPromotions = new ArrayCollection();
  268.         $this->cancelEventApplications = new ArrayCollection();
  269.         $this->companies = new ArrayCollection();
  270.         $this->affiliatedEventApplications = new ArrayCollection();
  271.     }
  272.     public function getId(): ?int
  273.     {
  274.         return $this->id;
  275.     }
  276.     public function getFirstName(): ?string
  277.     {
  278.         return $this->firstName;
  279.     }
  280.     public function setFirstName(string $firstName): self
  281.     {
  282.         $this->firstName $firstName;
  283.         $this->updateUsername();
  284.         return $this;
  285.     }
  286.     public function getLastName(): ?string
  287.     {
  288.         return $this->lastName;
  289.     }
  290.     public function setLastName(string $lastName): self
  291.     {
  292.         $this->lastName $lastName;
  293.         $this->updateUsername();
  294.         return $this;
  295.     }
  296.     public function updateUsername()
  297.     {
  298.         if ($this->user instanceof User) {
  299.             $this->user->setName($this->getFirstName() . ' ' $this->getLastName());
  300.         }
  301.     }
  302.     public function getCreatedAt(): ?\DateTime
  303.     {
  304.         return $this->createdAt;
  305.     }
  306.     public function setCreatedAt(\DateTime $createdAt): self
  307.     {
  308.         $this->createdAt $createdAt;
  309.         return $this;
  310.     }
  311.     public function getImage(): ?string
  312.     {
  313.         return $this->image;
  314.     }
  315.     public function setImage(?string $image): self
  316.     {
  317.         $this->image $image;
  318.         return $this;
  319.     }
  320.     public function getUser(): ?user
  321.     {
  322.         return $this->user;
  323.     }
  324.     public function setUser(User $user): self
  325.     {
  326.         $this->user $user;
  327.         $user->setSpecialist($this);
  328.         $this->user->updateName();
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return File|null
  333.      */
  334.     public function getImageFile(): ?File
  335.     {
  336.         return $this->imageFile;
  337.     }
  338.     /**
  339.      * @param File|null $imageFile
  340.      * @return Specialist
  341.      */
  342.     public function setImageFile(?File $imageFile null): Specialist
  343.     {
  344.         $this->imageFile $imageFile;
  345.         if ($imageFile) {
  346.             // if 'updatedAt' is not defined in your entity, use another property
  347.             $this->updatedAt = new \DateTime('now');
  348.         }
  349.         return $this;
  350.     }
  351.     public function getUpdatedAt(): ?\DateTime
  352.     {
  353.         return $this->updatedAt;
  354.     }
  355.     public function setUpdatedAt(?\DateTime $updatedAt): self
  356.     {
  357.         $this->updatedAt $updatedAt;
  358.         return $this;
  359.     }
  360.     /**
  361.      * @return Collection|SpecialistTag[]
  362.      */
  363.     public function getSpecialistTags(): Collection
  364.     {
  365.         return $this->specialistTags;
  366.     }
  367.     public function setSpecialistTags(array $specialistTags): self
  368.     {
  369.         $this->specialistTags = new ArrayCollection();
  370.         if (is_array($specialistTags)) {
  371.             // foreach ($this->specialistTags as $key => $specialistTag) {
  372.             //     $this->removeSpecialistTag($specialistTag);
  373.             // }
  374.             // foreach ($specialistTags as $key => $specialistTag) {
  375.             //     $this->addSpecialistTag($specialistTag);
  376.             //     $specialistTags[$key]->setSpecialist($this);
  377.             // }
  378.             $this->specialistTags = new ArrayCollection($specialistTags);
  379.         }
  380.         return $this;
  381.     }
  382.     public function addSpecialistTag(SpecialistTag $specialistTag): self
  383.     {
  384.         if (!$this->specialistTags->contains($specialistTag)) {
  385.             $this->specialistTags[] = $specialistTag;
  386.             $specialistTag->setSpecialist($this);
  387.         }
  388.         return $this;
  389.     }
  390.     public function removeSpecialistTag(SpecialistTag $specialistTag): self
  391.     {
  392.         if ($this->specialistTags->removeElement($specialistTag)) {
  393.             // set the owning side to null (unless already changed)
  394.             if ($specialistTag->getSpecialist() === $this) {
  395.                 $specialistTag->setSpecialist(null);
  396.             }
  397.         }
  398.         return $this;
  399.     }
  400.     /**
  401.      * @return Collection|Event[]
  402.      */
  403.     public function getEvents(): Collection
  404.     {
  405.         return $this->events;
  406.     }
  407.     public function addEvent(Event $event): self
  408.     {
  409.         if (!$this->events->contains($event)) {
  410.             $this->events[] = $event;
  411.             $event->setSpecialist($this);
  412.         }
  413.         return $this;
  414.     }
  415.     public function removeEvent(Event $event): self
  416.     {
  417.         if ($this->events->removeElement($event)) {
  418.             // set the owning side to null (unless already changed)
  419.             if ($event->getSpecialist() === $this) {
  420.                 $event->setSpecialist(null);
  421.             }
  422.         }
  423.         return $this;
  424.     }
  425.     public function __toString()
  426.     {
  427.         return $this->firstName ' ' $this->lastName;
  428.     }
  429.     /**
  430.      * @ORM\PrePersist()
  431.      */
  432.     public function prePersist()
  433.     {
  434.         $this->user->setCategory(User::GROUP_SPECIALIST);
  435.         $this->user->addRole(User::ROLE_SPECIALIST);
  436.     }
  437.     /**
  438.      * @return Collection|SpecialistEventApplication[]
  439.      */
  440.     public function getApplications(): Collection
  441.     {
  442.         return $this->applications;
  443.     }
  444.     public function addApplication(SpecialistEventApplication $application): self
  445.     {
  446.         if (!$this->applications->contains($application)) {
  447.             $this->applications[] = $application;
  448.             $application->setSpecialist($this);
  449.         }
  450.         return $this;
  451.     }
  452.     public function removeApplication(SpecialistEventApplication $application): self
  453.     {
  454.         if ($this->applications->removeElement($application)) {
  455.             // set the owning side to null (unless already changed)
  456.             if ($application->getSpecialist() === $this) {
  457.                 $application->setSpecialist(null);
  458.             }
  459.         }
  460.         return $this;
  461.     }
  462.     public function getRadius(): ?float
  463.     {
  464.         return $this->radius;
  465.     }
  466.     public function setRadius(float $radius): self
  467.     {
  468.         $this->radius $radius;
  469.         return $this;
  470.     }
  471.     /**
  472.      * @return Collection|Workshop[]
  473.      */
  474.     public function getWorkshops(): Collection
  475.     {
  476.         return $this->workshops;
  477.     }
  478.     public function addWorkshop(Workshop $workshop): self
  479.     {
  480.         if (!$this->workshops->contains($workshop)) {
  481.             $this->workshops[] = $workshop;
  482.             $workshop->setSpecialist($this);
  483.         }
  484.         return $this;
  485.     }
  486.     public function removeWorkshop(Workshop $workshop): self
  487.     {
  488.         if ($this->workshops->removeElement($workshop)) {
  489.             // set the owning side to null (unless already changed)
  490.             if ($workshop->getSpecialist() === $this) {
  491.                 $workshop->setSpecialist(null);
  492.             }
  493.         }
  494.         return $this;
  495.     }
  496.     public function getInComingEvents()
  497.     {
  498.         $inComingEvents = [];
  499.         if (!empty($this->getEvents()->toArray())) {
  500.             $today = new \DateTime("now");
  501.             foreach ($this->getEvents()->toArray() as $key => $event) {
  502.                 if ($event instanceof Event) {
  503.                     if (in_array($event->getStatus(), [Event::STATUS_VALID]) && $event->getStart() >= $today) {
  504.                         $inComingEvents[] = $event;
  505.                     }
  506.                 }
  507.             }
  508.         }
  509.         return $inComingEvents;
  510.     }
  511.     public function getPastEvents()
  512.     {
  513.         $pastEvents = [];
  514.         if (!empty($this->getEvents()->toArray())) {
  515.             $today = new \DateTime("now");
  516.             foreach ($this->getEvents()->toArray() as $key => $event) {
  517.                 if ($event instanceof Event) {
  518.                     if ($event->getEnd() <= $today) {
  519.                         $pastEvents[] = $event;
  520.                     }
  521.                 }
  522.             }
  523.         }
  524.         return $pastEvents;
  525.     }
  526.     public function getCanceledEvents()
  527.     {
  528.         $canceledEvents = [];
  529.         if (!empty($this->getEvents()->toArray())) {
  530.             foreach ($this->getEvents()->toArray() as $key => $event) {
  531.                 if ($event instanceof Event) {
  532.                     if (in_array($event->getStatus(), [Event::STATUS_CANCELEDEvent::STATUS_CANCELED_MAIL])) {
  533.                         $canceledEvents[] = $event;
  534.                     }
  535.                 }
  536.             }
  537.         }
  538.         return $canceledEvents;
  539.     }
  540.     public function getDescription(): ?string
  541.     {
  542.         return $this->description;
  543.     }
  544.     public function setDescription(?string $description): self
  545.     {
  546.         $this->description $description;
  547.         return $this;
  548.     }
  549.     public function getTel(): ?string
  550.     {
  551.         return $this->tel;
  552.     }
  553.     public function setTel(string $tel): self
  554.     {
  555.         $this->tel $tel;
  556.         return $this;
  557.     }
  558.     /**
  559.      * @return Collection<int, InvoiceApplication>
  560.      */
  561.     public function getInvoiceApplications(): Collection
  562.     {
  563.         return $this->invoiceApplications;
  564.     }
  565.     public function addInvoiceApplication(InvoiceApplication $invoiceApplication): self
  566.     {
  567.         if (!$this->invoiceApplications->contains($invoiceApplication)) {
  568.             $this->invoiceApplications[] = $invoiceApplication;
  569.             $invoiceApplication->setSpecialist($this);
  570.         }
  571.         return $this;
  572.     }
  573.     public function removeInvoiceApplication(InvoiceApplication $invoiceApplication): self
  574.     {
  575.         if ($this->invoiceApplications->removeElement($invoiceApplication)) {
  576.             // set the owning side to null (unless already changed)
  577.             if ($invoiceApplication->getSpecialist() === $this) {
  578.                 $invoiceApplication->setSpecialist(null);
  579.             }
  580.         }
  581.         return $this;
  582.     }
  583.     public function getPriceByEvent(Event $event)
  584.     {
  585.         $price null;
  586.         foreach ($this->specialistTags as $key => $specialistTag) {
  587.             if ($specialistTag->getTag() == $event->getWorkshop()->getTag()) {
  588.                 $price $specialistTag->getPrice();
  589.                 break;
  590.             }
  591.         }
  592.         return $price;
  593.     }
  594.     public function getIsTva(): ?bool
  595.     {
  596.         return $this->isTva;
  597.     }
  598.     public function setIsTva(bool $isTva): self
  599.     {
  600.         $this->isTva $isTva;
  601.         return $this;
  602.     }
  603.     /**
  604.      * @return Collection<int, CancelEventApplication>
  605.      */
  606.     public function getCancelEventApplications(): Collection
  607.     {
  608.         return $this->cancelEventApplications;
  609.     }
  610.     public function addCancelEventApplication(CancelEventApplication $cancelEventApplication): self
  611.     {
  612.         if (!$this->cancelEventApplications->contains($cancelEventApplication)) {
  613.             $this->cancelEventApplications[] = $cancelEventApplication;
  614.             $cancelEventApplication->setSpecialist($this);
  615.         }
  616.         return $this;
  617.     }
  618.     public function removeCancelEventApplication(CancelEventApplication $cancelEventApplication): self
  619.     {
  620.         if ($this->cancelEventApplications->removeElement($cancelEventApplication)) {
  621.             // set the owning side to null (unless already changed)
  622.             if ($cancelEventApplication->getSpecialist() === $this) {
  623.                 $cancelEventApplication->setSpecialist(null);
  624.             }
  625.         }
  626.         return $this;
  627.     }
  628.     public function getIsVirtualEvent(): ?bool
  629.     {
  630.         return $this->isVirtualEvent;
  631.     }
  632.     public function setIsVirtualEvent(bool $isVirtualEvent): self
  633.     {
  634.         $this->isVirtualEvent $isVirtualEvent;
  635.         return $this;
  636.     }
  637.     public function getStatus(): ?string
  638.     {
  639.         return $this->status;
  640.     }
  641.     public function setStatus(?string $status): self
  642.     {
  643.         $this->status $status;
  644.         return $this;
  645.     }
  646.     public function getStatusDate(): ?\DateTimeInterface
  647.     {
  648.         return $this->statusDate;
  649.     }
  650.     public function setStatusDate(?\DateTimeInterface $statusDate): self
  651.     {
  652.         $this->statusDate $statusDate;
  653.         return $this;
  654.     }
  655.     public function getIdentityCard(): ?string
  656.     {
  657.         return $this->identityCard;
  658.     }
  659.     /**
  660.      * @return File|null
  661.      */
  662.     public function getIdentityCardFile(): ?File
  663.     {
  664.         return $this->identityCardFile;
  665.     }
  666.     public function setIdentityCard(?string $identityCard): self
  667.     {
  668.         $this->identityCard $identityCard;
  669.         return $this;
  670.     }
  671.     /**
  672.      * @param File|null $identityCardFile
  673.      * @return Specialist
  674.      */
  675.     public function setIdentityCardFile(?File $identityCardFile null): Specialist
  676.     {
  677.         $this->identityCardFile $identityCardFile;
  678.         if ($identityCardFile) {
  679.             // if 'updatedAt' is not defined in your entity, use another property
  680.             $this->updatedAt = new \DateTime('now');
  681.         }
  682.         return $this;
  683.     }
  684.     public function getInsurance(): ?string
  685.     {
  686.         return $this->insurance;
  687.     }
  688.     /**
  689.      * @return File|null
  690.      */
  691.     public function getInsuranceFile(): ?File
  692.     {
  693.         return $this->insuranceFile;
  694.     }
  695.     public function setInsurance(?string $insurance): self
  696.     {
  697.         $this->insurance $insurance;
  698.         return $this;
  699.     }
  700.     /**
  701.      * @param File|null $insuranceFile
  702.      * @return Specialist
  703.      */
  704.     public function setInsuranceFile(?File $insuranceFile null): Specialist
  705.     {
  706.         $this->insuranceFile $insuranceFile;
  707.         if ($insuranceFile) {
  708.             // if 'updatedAt' is not defined in your entity, use another property
  709.             $this->updatedAt = new \DateTime('now');
  710.         }
  711.         return $this;
  712.     }
  713.     public function getDegree(): ?string
  714.     {
  715.         return $this->degree;
  716.     }
  717.     /**
  718.      * @return File|null
  719.      */
  720.     public function getDegreeFile(): ?File
  721.     {
  722.         return $this->degreeFile;
  723.     }
  724.     public function setDegree(?string $degree): self
  725.     {
  726.         $this->degree $degree;
  727.         return $this;
  728.     }
  729.     /**
  730.      * @param File|null $degreeFile
  731.      * @return Specialist
  732.      */
  733.     public function setDegreeFile(?File $degreeFile null): Specialist
  734.     {
  735.         $this->degreeFile $degreeFile;
  736.         if ($degreeFile) {
  737.             // if 'updatedAt' is not defined in your entity, use another property
  738.             $this->updatedAt = new \DateTime('now');
  739.         }
  740.         return $this;
  741.     }
  742.     public function getRib(): ?string
  743.     {
  744.         return $this->rib;
  745.     }
  746.     /**
  747.      * @return File|null
  748.      */
  749.     public function getRibFile(): ?File
  750.     {
  751.         return $this->ribFile;
  752.     }
  753.     public function setRib(?string $rib): self
  754.     {
  755.         $this->rib $rib;
  756.         return $this;
  757.     }
  758.     /**
  759.      * @param File|null $ribFile
  760.      * @return Specialist
  761.      */
  762.     public function setRibFile(?File $ribFile null): Specialist
  763.     {
  764.         $this->ribFile $ribFile;
  765.         if ($ribFile) {
  766.             // if 'updatedAt' is not defined in your entity, use another property
  767.             $this->updatedAt = new \DateTime('now');
  768.         }
  769.         return $this;
  770.     }
  771.     /**
  772.      * @return Collection<int, VisioEvent>
  773.      */
  774.     public function getVisioEvents(): Collection
  775.     {
  776.         return $this->visioEvents;
  777.     }
  778.     public function addVisioEvent(VisioEvent $visioEvent): self
  779.     {
  780.         if (!$this->visioEvents->contains($visioEvent)) {
  781.             $this->visioEvents[] = $visioEvent;
  782.             $visioEvent->setSpecialist($this);
  783.         }
  784.         return $this;
  785.     }
  786.     public function removeVisioEvent(VisioEvent $visioEvent): self
  787.     {
  788.         if ($this->visioEvents->removeElement($visioEvent)) {
  789.             // set the owning side to null (unless already changed)
  790.             if ($visioEvent->getSpecialist() === $this) {
  791.                 $visioEvent->setSpecialist(null);
  792.             }
  793.         }
  794.         return $this;
  795.     }
  796.     
  797.     public function getStatusMessage(): ?string
  798.     {
  799.         return $this->statusMessage;
  800.     }
  801.     public function setStatusMessage(?string $statusMessage): self
  802.     {
  803.         $this->statusMessage $statusMessage;
  804.         return $this;
  805.     }
  806.     /**
  807.      * @return VisioEvent[]
  808.      */
  809.     public function dayVisios(?\DateTime $dateTime nullint $max 5): array
  810.     {
  811.         $result = [];
  812.         if ($dateTime instanceof \DateTime) {
  813.             $today $dateTime->format('Y-m-d');
  814.         } else {
  815.             $today = (new \DateTime())->format('Y-m-d');
  816.         }
  817.         foreach ($this->getVisioEvents() as $visioEvent) {
  818.             if ($visioEvent->getStart()->format('Y-m-d') == $today &&
  819.             count($result) < $max && $visioEvent->getStart() > new \DateTime()) {
  820.                 $result[] = $visioEvent;
  821.             }
  822.         }
  823.         return $result;
  824.     }
  825.     /**
  826.      * @return VisioEvent[]
  827.      */
  828.     public function dayVisiosFiltered(?\DateTime $dateTime nullint $max 5bool $valid false): array
  829.     {
  830.         $result = [];
  831.         if ($dateTime instanceof \DateTime) {
  832.             $today $dateTime->format('Y-m-d');
  833.         } else {
  834.             $today = (new \DateTime())->format('Y-m-d');
  835.         }
  836.         foreach ($this->getVisioEvents() as $visioEvent) {
  837.             if ($visioEvent->getStart()->format('Y-m-d') == $today &&
  838.                 count($result) < $max && (!$valid || $visioEvent->isOpen())) {
  839.                 $result[] = $visioEvent;
  840.             }
  841.         }
  842.         return $result;
  843.     }
  844.     /**
  845.      * @param \DateTime|null $dateTime
  846.      * @param int $max
  847.      * @param bool $valid
  848.      * @param int $rank
  849.      * @return VisioEvent[]
  850.      */
  851.     public function dayVisiosNextDay(?\DateTime $dateTime nullint $max 5bool $valid falseint $rank 0): array
  852.     {
  853.         if ($dateTime == null){
  854.             $dateTime = new \DateTime();
  855.         }
  856.         $result $this->dayVisiosFiltered($dateTime$max$valid);
  857.         if (empty($result) && $rank 10){
  858.             $dateTime->modify('+1 day');
  859.             $result $this->dayVisiosNextDay($dateTime$max$valid, ++$rank);
  860.         }
  861.         return $result;
  862.     }
  863.     /**
  864.      * @return Collection<int, VisioEventPromotion>
  865.      */
  866.     public function getVisioEventPromotions(): Collection
  867.     {
  868.         return $this->visioEventPromotions;
  869.     }
  870.     public function addVisioEventPromotion(VisioEventPromotion $visioEventPromotion): self
  871.     {
  872.         if (!$this->visioEventPromotions->contains($visioEventPromotion)) {
  873.             $this->visioEventPromotions[] = $visioEventPromotion;
  874.             $visioEventPromotion->addSpecialist($this);
  875.         }
  876.         return $this;
  877.     }
  878.     
  879.     public function removeVisioEventPromotion(VisioEventPromotion $visioEventPromotion): self
  880.     {
  881.         if ($this->visioEventPromotions->removeElement($visioEventPromotion)) {
  882.             $visioEventPromotion->removeSpecialist($this);
  883.         }
  884.         return $this;
  885.     }
  886.     /**
  887.      * @Groups({"search"})
  888.      * @SerializedName("text")
  889.      * @return string
  890.      */
  891.     public function getText(): string
  892.     {
  893.         return (string)$this;
  894.     }
  895.     public function getUuid()
  896.     {
  897.         return $this->uuid;
  898.     }
  899.     public function setUuid($uuid): self
  900.     {
  901.         $this->uuid $uuid;
  902.         return $this;
  903.     }
  904.     /**
  905.      * @return bool
  906.      * @var Datetime $start
  907.      * @var Datetime $end
  908.      * Permet de savoir si il est disponible en fonction d'une date de début et de fin
  909.      */
  910.     public function isAvailable(\DateTime $start\DateTime $end): bool
  911.     {
  912.         $isAvailable true;
  913.         foreach($this->getEvents()->toArray() as $event)
  914.         {
  915.             if($event->isInComing()) {
  916.                 if($event->getStart() >= $start && $event->getStart() <= $end
  917.                     && $event->getEnd() >= $start && $event->getEnd() <= $end) {
  918.                         $isAvailable false;
  919.                 }
  920.             }
  921.         }
  922.         return $isAvailable;
  923.     }
  924.     public function getIsAffiliated(): ?bool
  925.     {
  926.         return $this->isAffiliated;
  927.     }
  928.     public function setIsAffiliated(?bool $isAffiliated): self
  929.     {
  930.         $this->isAffiliated $isAffiliated;
  931.         return $this;
  932.     }
  933.     public function getAffiliatedCompany(): ?Company
  934.     {
  935.         return $this->affiliatedCompany;
  936.     }
  937.     public function setAffiliatedCompany(?Company $affiliatedCompany): self
  938.     {
  939.         $this->affiliatedCompany $affiliatedCompany;
  940.         return $this;
  941.     }
  942.     /**
  943.      * @return Collection<int, Company>
  944.      */
  945.     public function getCompanies(): Collection
  946.     {
  947.         return $this->companies;
  948.     }
  949.     public function setCompanies(Collection $companies): self
  950.     {
  951.         $this->companies $companies;
  952.         return $this;
  953.     }
  954.     public function addCompany(Company $company): self
  955.     {
  956.         if (!$this->companies->contains($company)) {
  957.             $this->companies[] = $company;
  958.         }
  959.         return $this;
  960.     }
  961.     public function removeCompany(Company $company): self
  962.     {
  963.         $this->companies->removeElement($company);
  964.         return $this;
  965.     }
  966.     public function getspecialistType(): ?string
  967.     {
  968.        
  969.        
  970.         return $this->specialistType;
  971.     }
  972.     public function setspecialistType(?string $specialistType): self
  973.     {
  974.         $this->specialistType $specialistType;
  975.         return $this;
  976.     }
  977.     /**
  978.      * @return Collection<int, AffiliatedEventApplication>
  979.      */
  980.     public function getAffiliatedEventApplications(): Collection
  981.     {
  982.         return $this->affiliatedEventApplications;
  983.     }
  984.     public function addAffiliatedEventApplication(AffiliatedEventApplication $affiliatedEventApplication): self
  985.     {
  986.         if (!$this->affiliatedEventApplications->contains($affiliatedEventApplication)) {
  987.             $this->affiliatedEventApplications[] = $affiliatedEventApplication;
  988.             $affiliatedEventApplication->setSpecialist($this);
  989.         }
  990.         return $this;
  991.     }
  992.     public function removeAffiliatedEventApplication(AffiliatedEventApplication $affiliatedEventApplication): self
  993.     {
  994.         if ($this->affiliatedEventApplications->removeElement($affiliatedEventApplication)) {
  995.             // set the owning side to null (unless already changed)
  996.             if ($affiliatedEventApplication->getSpecialist() === $this) {
  997.                 $affiliatedEventApplication->setSpecialist(null);
  998.             }
  999.         }
  1000.         return $this;
  1001.     }
  1002.     public function getSiret(): ?string
  1003.     {
  1004.         return $this->siret;
  1005.     }
  1006.     public function setSiret(?string $siret): self
  1007.     {
  1008.         $this->siret $siret;
  1009.         return $this;
  1010.     }
  1011.    
  1012.     /**
  1013.      * @return Collection<int, Tag>
  1014.      */
  1015.     public function getTags(): ?Collection
  1016.     {
  1017.         if(!$this->specialistTags->isEmpty()) {
  1018.             $this->tags = new ArrayCollection();
  1019.             
  1020.             foreach($this->specialistTags as $specialistTag){
  1021.                 $this->tags->add($specialistTag->getTag());
  1022.             }
  1023.         }
  1024.         return $this->tags;
  1025.     }
  1026.     public function setTags(Collection $tags): self
  1027.     {
  1028.         $this->tags $tags;
  1029.         return $this;
  1030.     }
  1031.     public function addTag(Tag $tag): self
  1032.     {
  1033.         if (!$this->tags->contains($tag)) {
  1034.             $this->tags[] = $tag;
  1035.         }
  1036.         return $this;
  1037.     }
  1038.     public function removeTag(Tag $tag): self
  1039.     {
  1040.         $this->tags->removeElement($tag);
  1041.         return $this;
  1042.     }
  1043.     public function getImageUrl(): ?string
  1044.     {
  1045.         return $this->imageUrl;
  1046.     }
  1047.     public function setImageUrl(string $imageUrl): self
  1048.     {
  1049.         $this->imageUrl $imageUrl;
  1050.         return $this;
  1051.     }
  1052.     public function isFiveKWarningSent(): ?bool
  1053.     {
  1054.         return $this->fiveKWarningSent;
  1055.     }
  1056.     public function setIsFiveKWarningSent(bool $fiveKWarningSent): self
  1057.     {
  1058.         $this->fiveKWarningSent $fiveKWarningSent;
  1059.         return $this;
  1060.     }
  1061. }