src/Entity/Specialist.php line 23

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