src/Entity/Worker.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TimesheetStatusRepository;
  4. use App\Repository\WorkerRepository;
  5. use function Doctrine\Common\Cache\Psr6\get;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Event\LifecycleEventArgs;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use phpDocumentor\Reflection\Types\This;
  11. use Monolog\DateTimeImmutable;
  12. use PhpParser\ErrorHandler\Collecting;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  14. use Symfony\Component\Validator\Constraints\DateTime;
  15. use Symfony\Component\Serializer\Annotation\MaxDepth;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Doctrine\ORM\Mapping\Table;
  19. use Doctrine\ORM\Mapping\UniqueConstraint;
  20. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  21. use Doctrine\Common\Collections\Criteria;
  22. /**
  23.  * ORM\Entity(repositoryClass=WorkerRepository::class)
  24. */
  25. /**
  26.  * @ORM\HasLifecycleCallbacks
  27.  * @ORM\Entity(repositoryClass=WorkerRepository::class)
  28.  * @ORM\Table(
  29.  *      name="worker",
  30.  *      uniqueConstraints={
  31.  *          @ORM\UniqueConstraint(columns={"name", "surname", "birthday_at"}),
  32.  *          @ORM\UniqueConstraint(name="unique_phone_number", columns={"phone_number"}, options={"where": "(phone_number IS NOT NULL)"}),
  33.  *      },
  34.  * )
  35.  * UniqueEntity(
  36.  *      fields={"name", "surname", "birthday_at"},
  37.  *      message="League for given country already exists in database."
  38.  * )
  39.  */
  40. class Worker
  41. {
  42.     // Same Process processed via Entity Subscriber
  43.     /**
  44.      * @ORM\Id
  45.      * @ORM\GeneratedValue
  46.      * @ORM\Column(type="integer")
  47.      * @Groups({
  48.      *     "worker.manage.base",
  49.      *     "customer.smart.active.employees",
  50.      *     "timesheet.for.stakeholder",
  51.      *     "worker.manage.base.timesheet",
  52.      *     "customer.selected.project",
  53.      * 
  54.      *     "project.details.orders",
  55.      *     "order.detail",
  56.      *     "order.lead",
  57.      *
  58.      *     "timesheet.collected.base",
  59.      *
  60.      *     "worker.base",
  61.      *     "worker.core", "worker@core",
  62.      *
  63.      *     "worker.activity.substitution.worker.activity.worker.core"
  64.      * })
  65.      */
  66.     private $id;
  67.     /**
  68.      * TODO replace base with core
  69.      * @ORM\Column(type="string", length=255)
  70.      * @Groups({
  71.      *     "worker.manage.base",
  72.      *     "customer.joined.projects.assigned.team.leaders",
  73.      *     "customer.manage.base.team.lead",
  74.      *     "customer.smart.active.employees",
  75.      *     "timesheet.for.stakeholder",
  76.      *     "timesheet.for.customer",
  77.      *     "customer.selected.project",
  78.      * 
  79.      *     "project.details.orders",
  80.      *     "order.detail",
  81.      *     "order.lead",
  82.      *
  83.      *     "timesheet.collected.base",
  84.      *
  85.      *     "worker.base",
  86.      *     "worker.core", "worker@core",
  87.      *
  88.      *     "worker.substitution.core"
  89.      * })
  90.      */
  91.     private $name;
  92.     /**
  93.      * @ORM\Column(type="string", length=255)
  94.      * @Groups({"worker.manage.base",
  95.      *     "customer.joined.projects.assigned.team.leaders",
  96.      *     "customer.manage.base.team.lead",
  97.      *     "customer.smart.active.employees",
  98.      *     "timesheet.for.stakeholder",
  99.      *     "timesheet.for.customer",
  100.      *     "customer.selected.project",
  101.      * 
  102.      *     "project.details.orders",
  103.      *     "order.detail",
  104.      * 
  105.      *     "order.lead",
  106.      *
  107.      *     "timesheet.collected.base",
  108.      *
  109.      *     "worker.base",
  110.      *     "worker.core", "worker@core",
  111.      *
  112.      *     "worker.substitution.core"
  113.      * })
  114.      */
  115.     private $surname;
  116.         /**
  117.      * @Groups({
  118.      *     "customer.joined.projects.assigned.team.leaders",
  119.      *     "customer.manage.base.team.lead",
  120.      *     "customer.smart.active.employees",
  121.      *     "worker.manage.base",
  122.      *     "customer.selected.project",
  123.      *
  124.      *     "project.details.orders",
  125.      *     "order.detail",
  126.      *     "order.lead",
  127.      *     "worker.substitution.core",
  128.          *
  129.          *
  130.          * "worker.core", "worker@core"
  131.      *
  132.      *     })
  133.     */
  134.     private $full_name;
  135.     /**
  136.      * @deprecated use in WorkerActivities
  137.      * @ORM\Column(type="datetime_immutable", nullable=true)
  138.      */
  139.     private $entry_at;
  140.     /**
  141.      * @deprecated use in WorkerActivities
  142.      * @ORM\Column(type="datetime_immutable", nullable=true)
  143.      */
  144.     private $exit_at;
  145.     /**
  146.      * @ORM\Column(type="datetime_immutable", nullable=true)
  147.      * @Groups({
  148.      *     "worker.manage.base",
  149.      *     "worker.core", "worker@core"
  150.      * })
  151.      */
  152.     private $birthday_at;
  153.     /**
  154.      * @ORM\Column(type="string", length=255)
  155.      * @Gedmo\Slug(fields={"name", "surname"})
  156.      * @Groups({
  157.      *     "worker.manage.base",
  158.      *     "customer.smart.active.employees",
  159.      *     "worker.core", "worker@core"
  160.      * })
  161.      */
  162.     private $slug;
  163.     /**
  164.      * @ORM\ManyToMany(targetEntity=Qualification::class, inversedBy="workers", fetch="EXTRA_LAZY")
  165.      * @Groups({"worker.manage.base"})
  166.      */
  167.     private $qualifications;
  168.     /**
  169.      * @deprecated use in WorkerActivities
  170.      * @ORM\OneToMany(targetEntity=WorkerInProject::class, mappedBy="worker", orphanRemoval=true, fetch="EXTRA_LAZY")
  171.      * @ORM\OrderBy({"id":"DESC"})
  172.      * Groups({"worker.manage.base", "worker.manage.joined.projects"})
  173.      */
  174.     private $worker_in_projects;
  175.     /**
  176.      * @ORM\OneToMany(targetEntity=WorkerActivities::class, mappedBy="worker", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY" )
  177.      * @ORM\OrderBy({"id":"DESC"})
  178.      * @Groups({
  179.      *     "worker.manage.base",
  180.      *     "worker.actually.activity",
  181.      *     "worker.activities",
  182.      *
  183.      *     "worker@activities"
  184.      *
  185.      * })
  186.      *
  187.      */
  188.     private $worker_activities;
  189.     /**
  190.      * @deprecated use latest WorkerActivities
  191.      * Groups({"worker.actually.activity"})
  192.      */
  193.     private $worker_actually_activity;
  194.     /**
  195.      * @ORM\OneToMany(targetEntity=WorkerCertificates::class, mappedBy="worker", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY" )
  196.      * @Groups({"worker.manage.base"})
  197.      */
  198.     private $worker_certificates;
  199.     /**
  200.      * @deprecated use inside WorkerActivities
  201.      * @ORM\OneToMany(targetEntity=WorkerTimesheet::class, mappedBy="worker", cascade={"persist"}, cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY")
  202.      * Groups({
  203.      *     "worker.manage.base.timesheet",
  204.      *     "timesheet.for.stakeholder",
  205.      *     "timesheet.for.customer"
  206.      *     })
  207.      */
  208.     private $worker_timesheets;
  209.     /**
  210.      * @ORM\Column(type="decimal", precision=4, scale=2, nullable=true)
  211.      * @Groups({"worker.manage.base"})
  212.      */
  213.     private $daily_work_time;
  214.     /**
  215.      * @ORM\Column(type="decimal", precision=7, scale=2, nullable=true)
  216.      * @Groups({"worker.manage.base", "worker.manage.selected.worker.in.project", "worker.manage.joined.projects"})
  217.      */
  218.     private $cost_per_hour;
  219.     /**
  220.      * @ORM\Column(type="string", length=64, nullable=true, unique=false )
  221.      * @Groups({"worker.manage.base"})
  222.      */
  223.     private $personal_id;
  224.     // Additional param
  225.     private array $total_worked_time;
  226.     /**
  227.      * @ORM\Column(type="datetime_immutable", nullable=true)
  228.      */
  229.     private $created_at;
  230.     /**
  231.      * @ORM\Column(type="string", length=24 , nullable=true )
  232.      * @Groups({"worker.manage.base"})
  233.      */
  234.     private $phone_number;
  235.     /**
  236.      * @ORM\Column(type="string", length=255, nullable=true)
  237.      * @Groups({"worker.manage.base"})
  238.      */
  239.     private $uiid;
  240.     /**
  241.      * @ORM\Column(type="string", length=255, nullable=true)
  242.      * @Groups({"worker.manage.base", "customer.smart.active.employees"})
  243.      */
  244.     private $profile_image;
  245.     /**
  246.      * ____________________________________________________________________________________________________
  247.      * Event Listener Prop
  248.      * This prop Update during event.listener
  249.      * @Groups({"worker.manage.base", "customer.smart.active.employees"})
  250.      */
  251.     private $profile_image_full_path;
  252.     /**
  253.      * TODO bu ozellik EventListernes yada Subscriber uzerinden yapilacak
  254.      * Event Listener Prop
  255.      * This prop Update during event.listener
  256.      * @param string $profile_image_full_path
  257.      * @return Worker|null
  258.      */
  259.     public function setProfileImageFullPathstring $profile_image_full_path ): ?self {
  260.         $this->profile_image_full_path $profile_image_full_path;//  $this->getServiceArgumentFileDirs()['fetch'] . DIRECTORY_SEPARATOR . $this->getProfileImage();
  261.         return $this;
  262.     }
  263.     /**
  264.      * Event Listener Prop
  265.      */
  266.     public function getProfileImageFullPath(): ?string { return $this->profile_image_full_path/* $this->getServiceArgumentFileDirs()['fetch'] . DIRECTORY_SEPARATOR . $this->getProfileImage(); */ }
  267.     //  ____________________________________________________________________________________________________
  268.     /**
  269.      * @ORM\OneToMany(targetEntity=UserAppSettings::class, mappedBy="worker")
  270.      */
  271.     private $user_app_settings;
  272.     /**
  273.      * @ORM\ManyToMany(targetEntity=AccessRoles::class, inversedBy="workers")
  274.      */
  275.     private $worker_accessed_roles;
  276.     /**
  277.      * TODO islemler bittikten sonra cikar
  278.      * TODO this should be in WorkerActivities
  279.      * @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="order_lead")
  280.      */
  281.     private $projectOrders;
  282.     /**
  283.      * TODO thisi deprecated !!!!
  284.      * @deprecated use inside WorkerActivities
  285.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="worker", cascade={"persist", "remove"})
  286.      * @Groups({
  287.      *     "worker.user",
  288.      *     "worker_activity@user"
  289.      * })
  290.      */
  291.     private $user;
  292.     /**
  293.      * @Groups({
  294.      *     "worker.latest.activity",
  295.      *      "worker@latest_activity"
  296.      * })
  297.      }
  298.     */
  299.     private $latest_activity;
  300.     /**
  301.      * @return mixed
  302.      */
  303.     public function getLatestActivity()
  304.     {
  305.         $criteria Criteria::create();
  306.         $criteria->orderBy(['created_at' => Criteria::DESC])->setMaxResults(1);
  307.         /**@var WorkerActivities $latestActivity*/
  308.         $latestActivity $this->getWorkerActivities()->matching($criteria)->first();
  309.         $this->latest_activity $latestActivity ?? null;
  310.         return $this->latest_activity;
  311.     }
  312.     /**
  313.      * @return mixed
  314.      */
  315.     public function getTotalWorkedTime(): array
  316.     {
  317.         return $this->total_worked_time;
  318.     }
  319.     /**
  320.      * @param mixed $total_worked_time
  321.      */
  322.     public function setTotalWorkedTime( \DateInterval $total_worked_time ): void
  323.     {
  324.         $this->total_worked_time = [
  325.             "days" => $total_worked_time->days,
  326.             "month" => $total_worked_time->m,
  327.             "year" => $total_worked_time->y,
  328.         ];
  329.     }
  330.     /**
  331.      * @return mixed
  332.      */
  333.     public function getFullName()
  334.     {
  335.         return $this->full_name ?? $this->name " " $this->surname;
  336.     }
  337.     /**
  338.      * @param mixed $full_name
  339.      */
  340.     public function setFullName($full_name): void
  341.     {
  342.         $this->full_name $full_name;
  343.     }
  344.     public function __construct()
  345.     {
  346.         $this->qualifications = new ArrayCollection();
  347.         $this->projects = new ArrayCollection();
  348.         $this->worker_in_projects = new ArrayCollection();
  349.         $this->worker_activities = new ArrayCollection();
  350.         $this->worker_certificates = new ArrayCollection();
  351.         $this->worker_timesheets = new ArrayCollection();
  352.         $this->user_app_settings = new ArrayCollection();
  353.         $this->role = new ArrayCollection();
  354.         $this->worker_accessed_roles = new ArrayCollection();
  355.         // TODO this should be in WorkerActivities
  356.         $this->projectOrders = new ArrayCollection();
  357.         // $this->ordersWithDelegatedAccess = new ArrayCollection();
  358.     }
  359.     public function getId(): ?int
  360.     {
  361.         return $this->id;
  362.     }
  363.     public function getName(): ?string
  364.     {
  365.         return $this->name;
  366.     }
  367.     public function setName(string $name): self
  368.     {
  369.         $this->name $name;
  370.         return $this;
  371.     }
  372.     public function getSurname(): ?string
  373.     {
  374.         return $this->surname;
  375.     }
  376.     public function setSurname(string $surname): self
  377.     {
  378.         $this->surname $surname;
  379.         return $this;
  380.     }
  381.     public function getEntryAt(): ?\DateTimeImmutable
  382.     {
  383.         return $this->entry_at;
  384.     }
  385.     public function setEntryAt(?\DateTimeImmutable $entry_at): self
  386.     {
  387.         $this->entry_at $entry_at;
  388.         return $this;
  389.     }
  390.     public function getExitAt(): ?\DateTimeImmutable
  391.     {
  392.         return $this->exit_at;
  393.     }
  394.     public function setExitAt(?\DateTimeImmutable $exit_at): self
  395.     {
  396.         $this->exit_at $exit_at;
  397.         return $this;
  398.     }
  399.     public function getBirthdayAt(): ?\DateTimeImmutable
  400.     {
  401.         return $this->birthday_at;
  402.         // return (new \DateTimeImmutable($this->birthday_at))->format('d.m.Y');
  403.     }
  404.     public function setBirthdayAt(?\DateTimeImmutable $birthday_at): self
  405.     {
  406.         $this->birthday_at $birthday_at;
  407.         return $this;
  408.     }
  409.     public function getSlug(): ?string
  410.     {
  411.         return $this->slug;
  412.     }
  413.     public function setSlug(string $slug): self
  414.     {
  415.         $this->slug $slug;
  416.         return $this;
  417.     }
  418.     /**
  419.      * @return Collection<int, Qualification>
  420.      */
  421.     public function getQualifications(): ?Collection
  422.     {
  423.             return $this->qualifications;
  424.     }
  425.     public function addQualification(Qualification $qualification): self
  426.     {
  427.         if (!$this->qualifications->contains($qualification)) {
  428.             $this->qualifications[] = $qualification;
  429.         }
  430.         return $this;
  431.     }
  432.     public function removeQualification(Qualification $qualification): self
  433.     {
  434.         $this->qualifications->removeElement($qualification);
  435.         return $this;
  436.     }
  437.     /**
  438.      * @return Collection<int, WorkerInProject>
  439.      */
  440.     public function getWorkerInProjects(): ?Collection
  441.     {
  442.         return $this->worker_in_projects;
  443.     }
  444.     public function addWorkerInProject(WorkerInProject $workerInProject): self
  445.     {
  446.         if (!$this->worker_in_projects->contains($workerInProject)) {
  447.             $this->worker_in_projects[] = $workerInProject;
  448.             $workerInProject->setWorker($this);
  449.         }
  450.         return $this;
  451.     }
  452.     public function removeWorkerInProject(WorkerInProject $workerInProject): self
  453.     {
  454.         if ($this->worker_in_projects->removeElement($workerInProject)) {
  455.             // set the owning side to null (unless already changed)
  456.             if ($workerInProject->getWorker() === $this) {
  457.                 $workerInProject->setWorker(null);
  458.             }
  459.         }
  460.         return $this;
  461.     }
  462.     /**
  463.      * @return Collection<int, WorkerActivities>
  464.      */
  465.     public function getWorkerActivities(): Collection
  466.     {
  467.         return $this->worker_activities;
  468.     }
  469.     /**
  470.      * @return Collection<int, WorkerActivities>
  471.      */
  472.     public function getWorkerActuallyCustomer(): ?Customer
  473.     {
  474.         #dd($this->getWorkerActuallyActivity()['entity']->getCustomer());
  475.         return $this->getWorkerActuallyActivity() ? $this->getWorkerActuallyActivity()['entity']->getCustomer() : null;
  476.     }
  477.     public function setWorkerActuallyActivityWorkerActivities $workerActivity ): void
  478.     {
  479.         $this->worker_actually_activity $workerActivity;
  480.     }
  481.     public function getWorkerActuallyActivity()
  482.     {
  483.        // return $this->worker_actually_activity;
  484. //        $arr = $this->getWorkerActivities()->filter( function ( /**@var $workerActivity WorkerActivities*/ $workerActivity ){
  485. //            return is_null($workerActivity->getExitAt());
  486. //        })->toArray();
  487.         $simplified $this->getWorkerActivities()->map( function ( /**@var $workerActivity WorkerActivities*/ $workerActivity ){
  488.             return [
  489.                 "id" => $workerActivity->getId(),
  490.                 "entry_at" => $workerActivity->getEntryAt(),
  491.                 "exit_at" => $workerActivity->getExitAt(),
  492.                 "created_at" => $workerActivity->getCreatedAt(),
  493.                 "entity" => $workerActivity
  494.             ];
  495.         })->toArray();
  496.         usort($simplified, fn($a$b) => $b['created_at'] <=> $a['created_at']); // ID'ye göre azalan sıralama
  497.         return $simplified[0] ?? null// ID'si en büyük olan
  498.     }
  499.     public function addWorkerActivity(WorkerActivities $workerActivity): self
  500.     {
  501.         if (!$this->worker_activities->contains($workerActivity)) {
  502.             $this->worker_activities[] = $workerActivity;
  503.             $workerActivity->setWorker($this);
  504.         }
  505.         return $this;
  506.     }
  507.     public function removeWorkerActivity(WorkerActivities $workerActivity): self
  508.     {
  509.         if ($this->worker_activities->removeElement($workerActivity)) {
  510.             // set the owning side to null (unless already changed)
  511.             if ($workerActivity->getWorker() === $this) {
  512.                 $workerActivity->setWorker(null);
  513.             }
  514.         }
  515.         return $this;
  516.     }
  517.     /**
  518.      * @return Collection<int, WorkerCertificates>
  519.      */
  520.     public function getWorkerCertificates(): Collection
  521.     {
  522.         return $this->worker_certificates;
  523.     }
  524.     public function addWorkerCertificate(WorkerCertificates $workerCertificate): self
  525.     {
  526.         if (!$this->worker_certificates->contains($workerCertificate)) {
  527.             $this->worker_certificates[] = $workerCertificate;
  528.             $workerCertificate->setWorker($this);
  529.         }
  530.         return $this;
  531.     }
  532.     public function removeWorkerCertificate(WorkerCertificates $workerCertificate): self
  533.     {
  534.         if ($this->worker_certificates->removeElement($workerCertificate)) {
  535.             // set the owning side to null (unless already changed)
  536.             if ($workerCertificate->getWorker() === $this) {
  537.                 $workerCertificate->setWorker(null);
  538.             }
  539.         }
  540.         return $this;
  541.     }
  542.     /**
  543.      * @return Collection<int, WorkerTimesheet>
  544.      */
  545.     public function getWorkerTimesheets(): Collection
  546.     {
  547.         return $this->worker_timesheets;
  548.     }
  549.     public function addWorkerTimesheet(WorkerTimesheet $workerTimesheet): self
  550.     {
  551.         if (!$this->worker_timesheets->contains($workerTimesheet)) {
  552.             $this->worker_timesheets[] = $workerTimesheet;
  553.             $workerTimesheet->setWorker($this);
  554.         }
  555.         return $this;
  556.     }
  557.     public function removeWorkerTimesheet(WorkerTimesheet $workerTimesheet): self
  558.     {
  559.         if ($this->worker_timesheets->removeElement($workerTimesheet)) {
  560.             // set the owning side to null (unless already changed)
  561.             if ($workerTimesheet->getWorker() === $this) {
  562.                 $workerTimesheet->setWorker(null);
  563.             }
  564.         }
  565.         return $this;
  566.     }
  567.     public function getCostPerHour(): ?float
  568.     {
  569.         return $this->cost_per_hour;
  570.     }
  571.     public function setCostPerHour(?float $cost_per_hour): self
  572.     {
  573.         $this->cost_per_hour $cost_per_hour;
  574.         return $this;
  575.     }
  576.     public function getDailyWorkTime(): ?float
  577.     {
  578.         return $this->daily_work_time;
  579.     }
  580.     public function setDailyWorkTime(?float $daily_work_time): self
  581.     {
  582.         $this->daily_work_time $daily_work_time;
  583.         return $this;
  584.     }
  585.     public function getPersonalId(): ?string
  586.     {
  587.         return $this->personal_id;
  588.     }
  589.     public function setPersonalId(?string $personal_id): self
  590.     {
  591.         $this->personal_id $personal_id;
  592.         return $this;
  593.     }
  594.     public function getCreatedAt(): ?\DateTimeImmutable
  595.     {
  596.         return $this->created_at;
  597.     }
  598.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  599.     {
  600.         $this->created_at $created_at;
  601.         return $this;
  602.     }
  603.     public function getPhoneNumber(): ?string
  604.     {
  605.         return $this->phone_number;
  606.     }
  607.     public function setPhoneNumber(?string $phone_number): self
  608.     {
  609.         $this->phone_number $phone_number;
  610.         return $this;
  611.     }
  612.     public function getUiid(): ?string
  613.     {
  614.         return $this->uiid;
  615.     }
  616.     public function setUiid(?string $uiid): self
  617.     {
  618.         $this->uiid $uiid;
  619.         return $this;
  620.     }
  621.     public function getProfileImage(): ?string
  622.     {
  623.         return $this->profile_image;
  624.     }
  625.     public function setProfileImage(?string $profile_image): self
  626.     {
  627.         $this->profile_image $profile_image;
  628.         return $this;
  629.     }
  630.     /**
  631.      * @return Collection<int, UserAppSettings>
  632.      */
  633.     public function getUserAppSettings(): Collection
  634.     {
  635.         return $this->user_app_settings;
  636.     }
  637.     public function addUserAppSetting(UserAppSettings $userAppSetting): self
  638.     {
  639.         if (!$this->user_app_settings->contains($userAppSetting)) {
  640.             $this->user_app_settings[] = $userAppSetting;
  641.             $userAppSetting->setWorker($this);
  642.         }
  643.         return $this;
  644.     }
  645.     public function removeUserAppSetting(UserAppSettings $userAppSetting): self
  646.     {
  647.         if ($this->user_app_settings->removeElement($userAppSetting)) {
  648.             // set the owning side to null (unless already changed)
  649.             if ($userAppSetting->getWorker() === $this) {
  650.                 $userAppSetting->setWorker(null);
  651.             }
  652.         }
  653.         return $this;
  654.     }
  655.     /**
  656.      * @return Collection<int, AccessRoles>
  657.      */
  658.     public function getWorkerAccessedRoles(): Collection
  659.     {
  660.         return $this->worker_accessed_roles;
  661.     }
  662.     public function addWorkerAccessedRole(AccessRoles $workerAccessedRole): self
  663.     {
  664.         if (!$this->worker_accessed_roles->contains($workerAccessedRole)) {
  665.             $this->worker_accessed_roles[] = $workerAccessedRole;
  666.         }
  667.         return $this;
  668.     }
  669.     public function removeWorkerAccessedRole(AccessRoles $workerAccessedRole): self
  670.     {
  671.         $this->worker_accessed_roles->removeElement($workerAccessedRole);
  672.         return $this;
  673.     }
  674.     /**
  675.      * // TODO this should be in WorkerActivities
  676.      * @return Collection<int, ProjectOrders>
  677.      */
  678.     public function getProjectOrders(): Collection
  679.     {
  680.         return $this->projectOrders;
  681.     }
  682.     // TODO this should be in WorkerActivities
  683.     public function addProjectOrder(ProjectOrders $projectOrder): self
  684.     {
  685.         if (!$this->projectOrders->contains($projectOrder)) {
  686.             $this->projectOrders[] = $projectOrder;
  687.             $projectOrder->setOrderLead($this);
  688.         }
  689.         return $this;
  690.     }
  691.     // TODO this should be in WorkerActivities
  692.     public function removeProjectOrder(ProjectOrders $projectOrder): self
  693.     {
  694.         if ($this->projectOrders->removeElement($projectOrder)) {
  695.             // set the owning side to null (unless already changed)
  696.             if ($projectOrder->getOrderLead() === $this) {
  697.                 $projectOrder->setOrderLead(null);
  698.             }
  699.         }
  700.         return $this;
  701.     }
  702.     public function getUser(): ?User
  703.     {
  704.         return $this->user;
  705.     }
  706.     public function setUser(?User $user): self
  707.     {
  708.         $this->user $user;
  709.         return $this;
  710.     }
  711. }