src/Entity/User.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Table(name:"til_user")]
  10. #[ORM\Entity(repositoryClass:"App\Repository\UserRepository")]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     public function __toString(){
  14.         return $this->getSurname().' '.$this->getName();
  15.     }
  16.     public function displayFullNameAndAccountType(){
  17.         return $this->getSurname().' '.$this->getName().' ('.$this->getAccountType()->__toString().')';
  18.     }
  19.     public function getCanViewPermissionCategory($categorySlug){
  20.         foreach($this->permissions as $jt){
  21.             if($jt->getPermission()->getCategory()->getSlug() == $categorySlug){
  22.                 if($jt->getValue() != "")
  23.                     return true;
  24.             }
  25.         }
  26.         return false;
  27.     }
  28.     
  29.     public function getCanViewPermission($permissionSlug){
  30.         foreach($this->permissions as $jt){
  31.             if($jt->getPermission()->getSlug() == $permissionSlug){
  32.                 if($jt->getValue() != "")
  33.                     return true;
  34.                 else
  35.                     return false;
  36.             }
  37.         }
  38.         return false;
  39.     }
  40.     
  41.     public function getCanEditPermission($permissionSlug){
  42.         foreach($this->permissions as $jt){
  43.             if($jt->getPermission()->getSlug() == $permissionSlug){
  44.                 if($jt->getValue() == "rw")
  45.                     return true;
  46.                 else
  47.                     return false;
  48.             }
  49.         }
  50.         return false;
  51.     }
  52.     public function getPermissionType($permissionSlug){
  53.         foreach($this->permissions as $jt){
  54.             if($jt->getPermission()->getSlug() == $permissionSlug)
  55.                 return $jt->getValue();
  56.         }
  57.         return "";
  58.     }
  59.     public function getUnreadNotifications(){
  60.         $count 0;
  61.         foreach($this->getNotifications() as $n){
  62.             if($n->isPersonal() && !$n->isRead())
  63.                 $count++;
  64.         }
  65.         return $count;
  66.     }
  67.     public function printPdfName(){
  68.         return $this->surname.' '.substr($this->name01);
  69.     }
  70.     
  71.     public function getHasProvince($facilityProvince){
  72.         if($this->getAccountType()->getSlug() == "kam"){
  73.             foreach ($this->coveredProvinces as $province){
  74.                 if($province->getId() == $facilityProvince)
  75.                     return true;
  76.             }
  77.         }
  78.         return false;
  79.     }
  80.     public function getSellName(){
  81.         if($this->getAccountType()->getSlug() == "kam" && $this->getName() != "Tillomed")
  82.             return $this->surname' ' .$this->name;
  83.         elseif($this->getAccountType()->getSlug() == "kam" && $this->getName() == "Tillomed")
  84.             return "Vacant";
  85.         else
  86.             return "Customer Service";
  87.     }
  88.     public function getIsEligible($feature){
  89.         switch($feature){
  90.             case 'alarmBtn':
  91.                 if($this->getAccountType()->getSlug() == 'supervisor_mario' 
  92.                     || strpos($this->getAccountType()->getSlug(), "commercial") !== false 
  93.                     || $this->getAccountType()->getSlug() == 'kam'
  94.                     || $this->getAccountType()->getSlug() == 'administration')
  95.                     return true;
  96.         }
  97.         return false;
  98.     }
  99.     
  100.     public function getActualOdometer($month$year){
  101.         foreach($this->refundYears as $ry){
  102.             if($ry->getValue() == $year){
  103.                 foreach($ry->getRefundMonths() as $rm){
  104.                     if($rm->getValue() == $month)
  105.                         return $rm->getEndMonthOdometer();
  106.                 }
  107.             }
  108.         }
  109.         return 0;
  110.     }
  111.     
  112.     public function getActualKmPlusMinus($month$year){
  113.         $odometer $this->getActualOdometer($month$year);
  114.         foreach($this->refundYears as $ry){
  115.             foreach($ry->getRefundMonths() as $rm){
  116.                
  117.                 return  $odometer $l->getStartKm() - ($rm->getValue()*$l->getKmMonth());
  118.             }
  119.         }
  120.         foreach($this->leasings as $l){
  121.         }
  122.         return 0;
  123.     }
  124.     
  125.     public function getCurrentBudgetKamPercentage($date){
  126.         $year $date->format("Y");
  127.         if($date->format("m") < 4)
  128.             $year--;
  129.         foreach($this->budgetKams as $bk){
  130.             if($bk->getBudgetTotal()->getYear() == $year)
  131.                 return $bk->getPercentage();
  132.         }
  133.         return "0";
  134.     }
  135.     public function getUnclosedPresenceMonth(){
  136.         $months = array();
  137.         foreach($this->presenceYears as $py){
  138.             foreach($py->getPresenceMonths() as $pm){
  139.                 if($pm->getStatus() < 2){
  140.                     array_push($months$pm);
  141.                 }
  142.             }
  143.         }
  144.         return $months;
  145.     }
  146.     public function getMonthPresenceStats($month$year$startDate$endDate$filterType){
  147.         $presence 0;
  148.         $rol 0;
  149.         $holiday 0;
  150.         $transfer 0;
  151.         $permission 0;
  152.         $illness 0;
  153.         $meeting 0;
  154.         $congress 0;
  155.         foreach($this->presenceYears as $py){
  156.             if($filterType == "progressive"){
  157.                 if($month && ($py->getValue() == $year || $py->getValue() == $year 1)){
  158.                     foreach($py->getPresenceMonths() as $pm){
  159.                         if(($py->getValue() == $year && $pm->getValue() <= $month) || ($py->getValue() == $year && $pm->getValue() >= 4)){
  160.                             foreach($pm->getPresenceDays() as $pd){
  161.                                 if($pd->getJobHours() > 0)
  162.                                     $presence++;
  163.                                 $rol += $pd->getRol();
  164.                                 $holiday += $pd->getHoliday();
  165.                                 $transfer += $pd->getIsTransfer();
  166.                                 $permission += $pd->getPermission();
  167.                                 $illness += $pd->getIllness();
  168.                                 $meeting += $pd->getIsMeeting();
  169.                                 $congress += $pd->getIsCongress();
  170.                             }
  171.                         }
  172.                     }
  173.                 }
  174.                 elseif($month >= && $py->getValue() == $year){
  175.                     foreach($py->getPresenceMonths() as $pm){
  176.                         if($pm->getValue() >= && $pm->getValue() <= $month){
  177.                             foreach($pm->getPresenceDays() as $pd){
  178.                                 if($pd->getJobHours() > 0)
  179.                                     $presence++;
  180.                                 $rol += $pd->getRol();
  181.                                 $holiday += $pd->getHoliday();
  182.                                 $transfer += $pd->getIsTransfer();
  183.                                 $permission += $pd->getPermission();
  184.                                 $illness += $pd->getIllness();
  185.                                 $meeting += $pd->getIsMeeting();
  186.                                 $congress += $pd->getIsCongress();
  187.                             }
  188.                         }
  189.                     }
  190.                 }
  191.             }
  192.             elseif($filterType == "monthly"){
  193.                 if($py->getValue() == $year){
  194.                     foreach($py->getPresenceMonths() as $pm){
  195.                         if($pm->getValue() == $month){
  196.                             foreach($pm->getPresenceDays() as $pd){
  197.                                 if($pd->getJobHours() > 0)
  198.                                     $presence++;
  199.                                 $rol += $pd->getRol();
  200.                                 $holiday += $pd->getHoliday();
  201.                                 $transfer += $pd->getIsTransfer();
  202.                                 $permission += $pd->getPermission();
  203.                                 $illness += $pd->getIllness();
  204.                                 $meeting += $pd->getIsMeeting();
  205.                                 $congress += $pd->getIsCongress();
  206.                             }
  207.                         }
  208.                     }
  209.                 }
  210.             }
  211.             else{
  212.                 if($py->getValue() >= $startDate->format("Y") and $py->getValue() <= $endDate->format("Y")){
  213.                     foreach($py->getPresenceMonths() as $pm){
  214.                         foreach($pm->getPresenceDays() as $pd){
  215.                             if($pd->getDate()->format("Ymd") >= $startDate->format("Ymd") && $pd->getDate()->format("Ymd") <= $endDate->format("Ymd")){
  216.                                 if($pd->getJobHours() > 0)
  217.                                     $presence++;
  218.                                 $rol += $pd->getRol();
  219.                                 $holiday += $pd->getHoliday();
  220.                                 $transfer += $pd->getIsTransfer();
  221.                                 $permission += $pd->getPermission();
  222.                                 $illness += $pd->getIllness();
  223.                                 $meeting += $pd->getIsMeeting();
  224.                                 $congress += $pd->getIsCongress();
  225.                             }
  226.                         }
  227.                     }
  228.                 }
  229.             }
  230.         }
  231.         return array($presence$rol$holiday$transfer$permission$illness$meeting$congress);
  232.     }
  233.     public function getMonthRefundStats($month$year$filterType){
  234.         $types = array();
  235.         foreach($this->refundYears as $ry){
  236.             if($filterType == "progressive"){
  237.                 if($month && ($ry->getValue() == $year || $ry->getValue() == $year 1)){
  238.                     foreach($ry->getRefundMonths() as $rm){
  239.                         if(($ry->getValue() == $year && $rm->getValue() <= $month) || ($ry->getValue() == $year && $rm->getValue() >= 4)){
  240.                             foreach($rm->getRefundDays() as $rd){
  241.                                 foreach($rd->getRefunds() as $r){
  242.                                     $index $r->getRefundType()->getId();
  243.                                     if(array_key_exists($index$types)) 
  244.                                         $types[$index] += $r->getValue(); 
  245.                                     else 
  246.                                         $types[$index] = $r->getValue();
  247.                                 }
  248.                             }
  249.                         }
  250.                     }
  251.                 }
  252.                 elseif($month >= && $ry->getValue() == $year){
  253.                     foreach($ry->getRefundMonths() as $rm){
  254.                         if($rm->getValue() >= && $rm->getValue() <= $month){
  255.                             foreach($rm->getRefundDays() as $rd){
  256.                                 foreach($rd->getRefunds() as $r){
  257.                                     $index $r->getRefundType()->getId();
  258.                                     if(array_key_exists($index$types)) 
  259.                                         $types[$index] += $r->getValue(); 
  260.                                     else 
  261.                                         $types[$index] = $r->getValue();
  262.                                 }
  263.                             }
  264.                         }
  265.                     }
  266.                 }
  267.             }
  268.             else{
  269.                 if($ry->getValue() == $year){
  270.                     foreach($ry->getRefundMonths() as $rm){
  271.                         if($rm->getValue() == $month){
  272.                             foreach($rm->getRefundDays() as $rd){
  273.                                 foreach($rd->getRefunds() as $r){
  274.                                     $index $r->getRefundType()->getId();
  275.                                     if(array_key_exists($index$types)) 
  276.                                         $types[$index] += $r->getValue(); 
  277.                                     else 
  278.                                         $types[$index] = $r->getValue();
  279.                                 }
  280.                             }
  281.                         }
  282.                     }
  283.                 }
  284.             }
  285.         }
  286.         return $types;
  287.     }
  288.     #[ORM\Column(name:"id"type:"bigint")]
  289.     #[ORM\Id]
  290.     #[ORM\GeneratedValue(strategy:"AUTO")]
  291.     private ?string $id;
  292.     
  293.     #[ORM\Column(name:"email"type:"string"length:191unique:truenullable:true)]
  294.     private ?string $email;
  295.     
  296.     #[ORM\Column(name:"name"type:"string"length:191)]
  297.     private ?string $name;
  298.     
  299.     #[ORM\Column(name:"surname"type:"string"length:191)]
  300.     private ?string $surname;
  301.     
  302.     #[ORM\Column(name:"password"type:"string"length:191nullable:true)]
  303.     private ?string $password;
  304.     
  305.     #[ORM\Column(name:"directory_path"type:"string"length:191)]
  306.     private ?string $directoryPath;
  307.     
  308.     #[ORM\Column(name:"one_time_code"type:"string"length:191nullable:true)]
  309.     private ?string $oneTimeCode;
  310.     
  311.     #[ORM\Column(name:"role"type:"string"length:191)]
  312.     private ?string $role 'ROLE_USER';
  313.     #[ORM\Column(name:"expiration_one_time_code"type:"datetime"nullable:true)]
  314.     private ?\DateTimeInterface $expirationOneTimeCode;
  315.     
  316.     #[ORM\Column(name:"office_hours"type:"text"nullable:true)]
  317.     private ?string $officeHours;
  318.     
  319.     #[ORM\Column(name:"is_active"type:"boolean")]
  320.     private ?bool $active false;
  321.     
  322.     #[ORM\Column(name:"is_admin_active"type:"boolean")]
  323.     private ?bool $adminActive true;
  324.     
  325.     #[ORM\Column(name:"is_email_notification_active"type:"boolean")]
  326.     private ?bool $emailNotificationActive false;
  327.     
  328.     #[ORM\Column(name:"is_alert_read"type:"boolean")]
  329.     private ?bool $alertRead false;
  330.     
  331.     #[ORM\Column(name:"is_gdpr_sent"type:"boolean")]
  332.     private ?bool $gdprSent false;
  333.     
  334.     // ONE TO ONE
  335.     #[ORM\OneToOne(targetEntity:"App\Entity\UserPrivacy"mappedBy:"user"cascade:['remove''persist'])]
  336.     private $privacy;
  337.     
  338.     #[ORM\OneToOne(targetEntity:"App\Entity\UserProfile"mappedBy:"user"cascade:['remove''persist'])]
  339.     private $profile;
  340.     
  341.     #[ORM\OneToOne(targetEntity:"App\Entity\Employee"mappedBy:"user")]
  342.     private $employee;
  343.     // MANY TO ONE
  344.     #[ORM\ManyToOne(targetEntity:"App\Entity\UserAccountType"inversedBy:"users")]
  345.     #[ORM\JoinColumn(name:"account_type_id"referencedColumnName:"id")]
  346.     private $accountType;
  347.     // ONE TO MANY
  348.     #[ORM\OneToMany(targetEntity:'App\Entity\Document'mappedBy:'owner')]
  349.     private $uploads;
  350.     
  351.     #[ORM\OneToMany(targetEntity:'App\Entity\Document'mappedBy:'user')]
  352.     private $documents;
  353.    
  354.     #[ORM\OneToMany(targetEntity:'App\Entity\Notification'mappedBy:'user')]
  355.     private $notifications;
  356.     
  357.     #[ORM\OneToMany(targetEntity:'App\Entity\Log'mappedBy:'user')]
  358.     private $logs;
  359.     #[ORM\OneToMany(targetEntity:'App\Entity\JoinTableUserTest'mappedBy:'user')]
  360.     private $tests;
  361.     #[ORM\OneToMany(targetEntity:'App\Entity\TestCode'mappedBy:'user')]
  362.     private $codes;
  363.     
  364.     #[ORM\OneToMany(targetEntity:'App\Entity\TestAnswer'mappedBy:'user')]
  365.     private $answers;
  366.     
  367.     #[ORM\OneToMany(targetEntity:'App\Entity\JoinTableUserPermission'mappedBy:'user')]
  368.     private $permissions;
  369.     public function __construct()
  370.     {
  371.         $this->uploads = new ArrayCollection();
  372.         $this->documents = new ArrayCollection();
  373.         $this->notifications = new ArrayCollection();
  374.         $this->logs = new ArrayCollection();
  375.         $this->departments = new ArrayCollection();
  376.         $this->tests = new ArrayCollection();
  377.         $this->codes = new ArrayCollection();
  378.         $this->answers = new ArrayCollection();
  379.         $this->permissions = new ArrayCollection();
  380.     }
  381.     /**
  382.      * @inheritdoc
  383.      */
  384.     public function getRoles(): array
  385.     {
  386.         switch($this->role){
  387.             case 'ROLE_ADMIN': return array('ROLE_ADMIN');
  388.             case 'ROLE_USER': return array('ROLE_USER');
  389.         }
  390.     }
  391.     public function getSalt(): ?string
  392.     {
  393.         return null;
  394.     }
  395.     /**
  396.      * @see UserInterface
  397.      */
  398.     public function eraseCredentials()
  399.     {
  400.     }
  401.     public function getUserIdentifier(): string
  402.     {
  403.         return (string) $this->email;
  404.     }
  405.     public function getUsername(): string
  406.     {
  407.         return null;
  408.     }
  409.     /**
  410.      * @see PasswordAuthenticatedUserInterface
  411.      */
  412.     public function getPassword(): string
  413.     {
  414.         return $this->password;
  415.     }
  416.     public function setPassword(string $password): self
  417.     {
  418.         $this->password $password;
  419.         return $this;
  420.     }
  421.     public function getId(): ?string
  422.     {
  423.         return $this->id;
  424.     }
  425.     public function getEmail(): ?string
  426.     {
  427.         return $this->email;
  428.     }
  429.     public function setEmail(?string $email): static
  430.     {
  431.         $this->email $email;
  432.         return $this;
  433.     }
  434.     public function getName(): ?string
  435.     {
  436.         return $this->name;
  437.     }
  438.     public function setName(string $name): static
  439.     {
  440.         $this->name $name;
  441.         return $this;
  442.     }
  443.     public function getSurname(): ?string
  444.     {
  445.         return $this->surname;
  446.     }
  447.     public function setSurname(string $surname): static
  448.     {
  449.         $this->surname $surname;
  450.         return $this;
  451.     }
  452.     public function getDirectoryPath(): ?string
  453.     {
  454.         return $this->directoryPath;
  455.     }
  456.     public function setDirectoryPath(string $directoryPath): static
  457.     {
  458.         $this->directoryPath $directoryPath;
  459.         return $this;
  460.     }
  461.     public function getOneTimeCode(): ?string
  462.     {
  463.         return $this->oneTimeCode;
  464.     }
  465.     public function setOneTimeCode(?string $oneTimeCode): static
  466.     {
  467.         $this->oneTimeCode $oneTimeCode;
  468.         return $this;
  469.     }
  470.     public function getRole(): ?string
  471.     {
  472.         return $this->role;
  473.     }
  474.     public function setRole(string $role): static
  475.     {
  476.         $this->role $role;
  477.         return $this;
  478.     }
  479.     public function getExpirationOneTimeCode(): ?\DateTimeInterface
  480.     {
  481.         return $this->expirationOneTimeCode;
  482.     }
  483.     public function setExpirationOneTimeCode(?\DateTimeInterface $expirationOneTimeCode): static
  484.     {
  485.         $this->expirationOneTimeCode $expirationOneTimeCode;
  486.         return $this;
  487.     }
  488.     public function getOfficeHours(): ?string
  489.     {
  490.         return $this->officeHours;
  491.     }
  492.     public function setOfficeHours(?string $officeHours): static
  493.     {
  494.         $this->officeHours $officeHours;
  495.         return $this;
  496.     }
  497.     public function isActive(): ?bool
  498.     {
  499.         return $this->active;
  500.     }
  501.     public function setActive(bool $active): static
  502.     {
  503.         $this->active $active;
  504.         return $this;
  505.     }
  506.     public function isAdminActive(): ?bool
  507.     {
  508.         return $this->adminActive;
  509.     }
  510.     public function setAdminActive(bool $adminActive): static
  511.     {
  512.         $this->adminActive $adminActive;
  513.         return $this;
  514.     }
  515.     public function isEmailNotificationActive(): ?bool
  516.     {
  517.         return $this->emailNotificationActive;
  518.     }
  519.     public function setEmailNotificationActive(bool $emailNotificationActive): static
  520.     {
  521.         $this->emailNotificationActive $emailNotificationActive;
  522.         return $this;
  523.     }
  524.     public function isAlertRead(): ?bool
  525.     {
  526.         return $this->alertRead;
  527.     }
  528.     public function setAlertRead(bool $alertRead): static
  529.     {
  530.         $this->alertRead $alertRead;
  531.         return $this;
  532.     }
  533.     public function isGdprSent(): ?bool
  534.     {
  535.         return $this->gdprSent;
  536.     }
  537.     public function setGdprSent(bool $gdprSent): static
  538.     {
  539.         $this->gdprSent $gdprSent;
  540.         return $this;
  541.     }
  542.     public function getPrivacy(): ?UserPrivacy
  543.     {
  544.         return $this->privacy;
  545.     }
  546.     public function setPrivacy(?UserPrivacy $privacy): static
  547.     {
  548.         // unset the owning side of the relation if necessary
  549.         if ($privacy === null && $this->privacy !== null) {
  550.             $this->privacy->setUser(null);
  551.         }
  552.         // set the owning side of the relation if necessary
  553.         if ($privacy !== null && $privacy->getUser() !== $this) {
  554.             $privacy->setUser($this);
  555.         }
  556.         $this->privacy $privacy;
  557.         return $this;
  558.     }
  559.     public function getProfile(): ?UserProfile
  560.     {
  561.         return $this->profile;
  562.     }
  563.     public function setProfile(?UserProfile $profile): static
  564.     {
  565.         // unset the owning side of the relation if necessary
  566.         if ($profile === null && $this->profile !== null) {
  567.             $this->profile->setUser(null);
  568.         }
  569.         // set the owning side of the relation if necessary
  570.         if ($profile !== null && $profile->getUser() !== $this) {
  571.             $profile->setUser($this);
  572.         }
  573.         $this->profile $profile;
  574.         return $this;
  575.     }
  576.     public function getEmployee(): ?Employee
  577.     {
  578.         return $this->employee;
  579.     }
  580.     public function setEmployee(?Employee $employee): static
  581.     {
  582.         // unset the owning side of the relation if necessary
  583.         if ($employee === null && $this->employee !== null) {
  584.             $this->employee->setUser(null);
  585.         }
  586.         // set the owning side of the relation if necessary
  587.         if ($employee !== null && $employee->getUser() !== $this) {
  588.             $employee->setUser($this);
  589.         }
  590.         $this->employee $employee;
  591.         return $this;
  592.     }
  593.     public function getAccountType(): ?UserAccountType
  594.     {
  595.         return $this->accountType;
  596.     }
  597.     public function setAccountType(?UserAccountType $accountType): static
  598.     {
  599.         $this->accountType $accountType;
  600.         return $this;
  601.     }
  602.     /**
  603.      * @return Collection<int, Document>
  604.      */
  605.     public function getUploads(): Collection
  606.     {
  607.         return $this->uploads;
  608.     }
  609.     public function addUpload(Document $upload): static
  610.     {
  611.         if (!$this->uploads->contains($upload)) {
  612.             $this->uploads->add($upload);
  613.             $upload->setOwner($this);
  614.         }
  615.         return $this;
  616.     }
  617.     public function removeUpload(Document $upload): static
  618.     {
  619.         if ($this->uploads->removeElement($upload)) {
  620.             // set the owning side to null (unless already changed)
  621.             if ($upload->getOwner() === $this) {
  622.                 $upload->setOwner(null);
  623.             }
  624.         }
  625.         return $this;
  626.     }
  627.     /**
  628.      * @return Collection<int, Document>
  629.      */
  630.     public function getDocuments(): Collection
  631.     {
  632.         return $this->documents;
  633.     }
  634.     public function addDocument(Document $document): static
  635.     {
  636.         if (!$this->documents->contains($document)) {
  637.             $this->documents->add($document);
  638.             $document->setUser($this);
  639.         }
  640.         return $this;
  641.     }
  642.     public function removeDocument(Document $document): static
  643.     {
  644.         if ($this->documents->removeElement($document)) {
  645.             // set the owning side to null (unless already changed)
  646.             if ($document->getUser() === $this) {
  647.                 $document->setUser(null);
  648.             }
  649.         }
  650.         return $this;
  651.     }
  652.     /**
  653.      * @return Collection<int, Notification>
  654.      */
  655.     public function getNotifications(): Collection
  656.     {
  657.         return $this->notifications;
  658.     }
  659.     public function addNotification(Notification $notification): static
  660.     {
  661.         if (!$this->notifications->contains($notification)) {
  662.             $this->notifications->add($notification);
  663.             $notification->setUser($this);
  664.         }
  665.         return $this;
  666.     }
  667.     public function removeNotification(Notification $notification): static
  668.     {
  669.         if ($this->notifications->removeElement($notification)) {
  670.             // set the owning side to null (unless already changed)
  671.             if ($notification->getUser() === $this) {
  672.                 $notification->setUser(null);
  673.             }
  674.         }
  675.         return $this;
  676.     }
  677.     /**
  678.      * @return Collection<int, Log>
  679.      */
  680.     public function getLogs(): Collection
  681.     {
  682.         return $this->logs;
  683.     }
  684.     public function addLog(Log $log): static
  685.     {
  686.         if (!$this->logs->contains($log)) {
  687.             $this->logs->add($log);
  688.             $log->setUser($this);
  689.         }
  690.         return $this;
  691.     }
  692.     public function removeLog(Log $log): static
  693.     {
  694.         if ($this->logs->removeElement($log)) {
  695.             // set the owning side to null (unless already changed)
  696.             if ($log->getUser() === $this) {
  697.                 $log->setUser(null);
  698.             }
  699.         }
  700.         return $this;
  701.     }
  702.     /**
  703.      * @return Collection<int, HospitalDepartmentReferent>
  704.      */
  705.     public function getDepartments(): Collection
  706.     {
  707.         return $this->departments;
  708.     }
  709.     public function addDepartment(HospitalDepartmentReferent $department): static
  710.     {
  711.         if (!$this->departments->contains($department)) {
  712.             $this->departments->add($department);
  713.             $department->setUser($this);
  714.         }
  715.         return $this;
  716.     }
  717.     public function removeDepartment(HospitalDepartmentReferent $department): static
  718.     {
  719.         if ($this->departments->removeElement($department)) {
  720.             // set the owning side to null (unless already changed)
  721.             if ($department->getUser() === $this) {
  722.                 $department->setUser(null);
  723.             }
  724.         }
  725.         return $this;
  726.     }
  727.     /**
  728.      * @return Collection<int, JoinTableUserTest>
  729.      */
  730.     public function getTests(): Collection
  731.     {
  732.         return $this->tests;
  733.     }
  734.     public function addTest(JoinTableUserTest $test): static
  735.     {
  736.         if (!$this->tests->contains($test)) {
  737.             $this->tests->add($test);
  738.             $test->setUser($this);
  739.         }
  740.         return $this;
  741.     }
  742.     public function removeTest(JoinTableUserTest $test): static
  743.     {
  744.         if ($this->tests->removeElement($test)) {
  745.             // set the owning side to null (unless already changed)
  746.             if ($test->getUser() === $this) {
  747.                 $test->setUser(null);
  748.             }
  749.         }
  750.         return $this;
  751.     }
  752.     /**
  753.      * @return Collection<int, TestCode>
  754.      */
  755.     public function getCodes(): Collection
  756.     {
  757.         return $this->codes;
  758.     }
  759.     public function addCode(TestCode $code): static
  760.     {
  761.         if (!$this->codes->contains($code)) {
  762.             $this->codes->add($code);
  763.             $code->setUser($this);
  764.         }
  765.         return $this;
  766.     }
  767.     public function removeCode(TestCode $code): static
  768.     {
  769.         if ($this->codes->removeElement($code)) {
  770.             // set the owning side to null (unless already changed)
  771.             if ($code->getUser() === $this) {
  772.                 $code->setUser(null);
  773.             }
  774.         }
  775.         return $this;
  776.     }
  777.     /**
  778.      * @return Collection<int, TestAnswer>
  779.      */
  780.     public function getAnswers(): Collection
  781.     {
  782.         return $this->answers;
  783.     }
  784.     public function addAnswer(TestAnswer $answer): static
  785.     {
  786.         if (!$this->answers->contains($answer)) {
  787.             $this->answers->add($answer);
  788.             $answer->setUser($this);
  789.         }
  790.         return $this;
  791.     }
  792.     public function removeAnswer(TestAnswer $answer): static
  793.     {
  794.         if ($this->answers->removeElement($answer)) {
  795.             // set the owning side to null (unless already changed)
  796.             if ($answer->getUser() === $this) {
  797.                 $answer->setUser(null);
  798.             }
  799.         }
  800.         return $this;
  801.     }
  802.     /**
  803.      * @return Collection<int, JoinTableUserPermission>
  804.      */
  805.     public function getPermissions(): Collection
  806.     {
  807.         return $this->permissions;
  808.     }
  809.     public function addPermission(JoinTableUserPermission $permission): static
  810.     {
  811.         if (!$this->permissions->contains($permission)) {
  812.             $this->permissions->add($permission);
  813.             $permission->setUser($this);
  814.         }
  815.         return $this;
  816.     }
  817.     public function removePermission(JoinTableUserPermission $permission): static
  818.     {
  819.         if ($this->permissions->removeElement($permission)) {
  820.             // set the owning side to null (unless already changed)
  821.             if ($permission->getUser() === $this) {
  822.                 $permission->setUser(null);
  823.             }
  824.         }
  825.         return $this;
  826.     }
  827. }