src/Entity/WorkerInProject.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WorkerInProjectRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Doctrine\ORM\Event\LifecycleEventArgs;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use phpDocumentor\Reflection\Types\This;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Serializer\Annotation\MaxDepth;
  12. use Symfony\Component\Validator\Constraints\Date;
  13. /**
  14.  * @ORM\Entity(repositoryClass=WorkerInProjectRepository::class)
  15.  * @ORM\HasLifecycleCallbacks
  16.  */
  17. class WorkerInProject
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      * @Groups({
  24.      *     "customer.joined.projects.assigned.team.leaders",
  25.      *     "worker.manage.joined.projects",
  26.      *     "worker.manage.selectable.stakeholder.projects",
  27.      *     "worker.manage.selected.worker.in.project",
  28.      *
  29.      *
  30.      *     "worker.in.project.base"
  31.      *
  32.      * })
  33.      */
  34.     private $id;
  35.     /**
  36.      * /// TODO Remove this prop
  37.      * @deprecated
  38.      * over worker_activity
  39.      * @ORM\ManyToOne(targetEntity=Worker::class, inversedBy="workerInProjects")
  40.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  41.      * @MaxDepth(2)
  42.      *      "timesheet.for.stakeholder",
  43.      *      "timesheet.for.customer"
  44.      * Groups({
  45.      *     "customer.joined.projects.assigned.team.leaders",
  46.      *     })
  47.      */
  48.     private $worker;
  49.     /**
  50.      * Stakeholder Level
  51.      * Info: Assigned to Project Stakeholder -> StakeHolder assigned to Project
  52.      * @ORM\ManyToOne(targetEntity=ProjectStakeholders::class, inversedBy="workerInProjects")
  53.      * @ORM\JoinColumn(nullable=false, options={"comment": "Project StakeholderId"}, onDelete="CASCADE")
  54.      * @MaxDepth(2)
  55.      * @Groups({
  56.      *     "worker.manage.joined.projects",
  57.      *     "worker.manage.selectable.stakeholder.projects",
  58.      *     "worker.manage.selected.worker.in.project"
  59.      * })
  60.      */
  61.     private $project;
  62.     /**
  63.      * @ORM\Column(type="datetime_immutable", nullable=true)
  64.      * @Groups({
  65.      *     "worker.manage.joined.projects",
  66.      *     "worker.manage.selected.worker.in.project"
  67.      * })
  68.      */
  69.     private $start_at;
  70.     /**
  71.      * @ORM\Column(type="datetime_immutable", nullable=true)
  72.      * @Groups({
  73.      *     "worker.manage.joined.projects",
  74.      *     "worker.manage.selected.worker.in.project"
  75.      * })
  76.      */
  77.     private $end_at;
  78.     /**
  79.      * @ORM\Column(type="datetime_immutable")
  80.      */
  81.     private $created_at;
  82.     /**
  83.      * ----------------------------------------------------------------------------------------------------------------
  84.      * This is custom column not associated to table
  85.      * Event Listener Prop
  86.      * This prop Update during event.listener
  87.      * @Groups({
  88.      *     "worker.manage.joined.projects",
  89.      *     "worker.manage.selectable.stakeholder.projects",
  90.      *     "worker.manage.selected.worker.in.project"
  91.      * })
  92.     */
  93.     private $status;
  94.     /**
  95.      * Event Listener Prop
  96.      * This prop Update during event.listener
  97.      * @param array $status
  98.      */
  99.     public function setStatus( array $status ): void {
  100.         $this->status $status;
  101.     }
  102.     /** * Event Listener Prop */
  103.     public function getStatus(){
  104.         return $this->status;
  105.     }
  106.     // ----------------------------------------------------------------------------------------------------------------
  107.     /**
  108.      * @ORM\Column(type="boolean", nullable=true)
  109.      * @Groups({
  110.      *     "worker.manage.joined.projects",
  111.      *     "worker.manage.selected.worker.in.project"
  112.      * })
  113.      */
  114.     private $forcibly_completed;
  115.     /**
  116.      * @ORM\ManyToMany(targetEntity=Qualification::class, inversedBy="workerInProjects")
  117.      * @Groups({
  118.      *     "worker.manage.joined.projects",
  119.      *     "worker.manage.selected.worker.in.project"
  120.      * })
  121.      */
  122.     private $assigned_qualifications;
  123.     /**
  124.      * @ORM\Column(type="decimal", precision=7, scale=2, nullable=true)
  125.      * @Groups({"worker.manage.selected.worker.in.project", "worker.manage.joined.projects"})
  126.      */
  127.     private $cost_per_hour;
  128.     /**
  129.      * @ORM\Column(type="boolean", nullable=true, options={"comment": "Worker for App Check-In/Out anywhere without coords just for joined project"})
  130.      * @Groups({"worker.manage.selected.worker.in.project"})
  131.      */
  132.     private $can_app_check_anywhere;
  133.     /**
  134.      * @ORM\ManyToMany(targetEntity=ProjectBranches::class, inversedBy="workerInProjects")
  135.      * @Groups({
  136.      *     "worker.manage.joined.projects",
  137.      *     "worker.manage.selected.worker.in.project",
  138.      *     "customer.selected.project",
  139.      *
  140.      *     "worker.in.project.assigned.project.branches"
  141.      * })
  142.      */
  143.     private $assigned_project_branches;
  144.     /**
  145.      * If you change the name of table, this is a important risk for data, will lost all
  146.      * Before you replace the name of table should backup!!
  147.      * @ORM\ManyToMany(targetEntity=ProjectBranches::class, inversedBy="project_branch_team_leaders")
  148.      * ORM\JoinTable(name="worker_in_project_project_branches_team_leaders",
  149.      *     joinColumns={@ORM\JoinColumn(name="worker_in_project_id", referencedColumnName="id")},
  150.      *     inverseJoinColumns={@ORM\JoinColumn(name="project_branch_id", referencedColumnName="id")}
  151.      *     )
  152.      * @ORM\JoinTable(name="worker_in_project_project_branches_team_leaders")
  153.      * @Groups({
  154.      *     "worker.manage.joined.projects",
  155.      *     "worker.manage.selected.worker.in.project"
  156.      * })
  157.      */
  158.     private $project_branches_team_leader;
  159.     /**
  160.      * @ORM\ManyToOne(targetEntity=WorkerActivities::class, inversedBy="worker_in_projects")
  161.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  162.      * @MaxDepth(2)
  163.      * @Groups({
  164.      *     "customer.joined.projects.assigned.team.leaders",
  165.      *     "timesheet.for.stakeholder",
  166.      *     "timesheet.for.customer",
  167.      *     "customer.selected.project",
  168.      *
  169.      *
  170.      *     "worker.in.project.worker.activity"
  171.      * })
  172.      */
  173.     private $worker_activity;
  174.     public function __construct()
  175.     {
  176.         $this->assigned_qualifications = new ArrayCollection();
  177.         $this->assigned_project_branches = new ArrayCollection();
  178.         $this->project_branches_team_leader = new ArrayCollection();
  179.     }
  180.     public function getId(): ?int
  181.     {
  182.         return $this->id;
  183.     }
  184.     /**@deprecated
  185.      * Fetch over WorkerActivity*/
  186.     public function getWorker(): ?Worker
  187.     {
  188.         return $this->worker;
  189.     }
  190.     /**@deprecated
  191.      * Fetch over WorkerActivity*/
  192.     public function setWorker(?Worker $worker): self
  193.     {
  194.         $this->worker $worker;
  195.         return $this;
  196.     }
  197.     public function getProject(): ?ProjectStakeholders
  198.     {
  199.         return $this->project;
  200.     }
  201.     public function setProject(?ProjectStakeholders $project): self
  202.     {
  203.         $this->project $project;
  204.         return $this;
  205.     }
  206.     public function getStartAt(): ?\DateTimeImmutable
  207.     {
  208.         return $this->start_at;
  209.     }
  210.     public function setStartAt(?\DateTimeImmutable $start_at): self
  211.     {
  212.         $this->start_at $start_at;
  213.         return $this;
  214.     }
  215.     public function getEndAt(): ?\DateTimeImmutable
  216.     {
  217.         return $this->end_at;
  218.     }
  219.     public function setEndAt(?\DateTimeImmutable $end_at): self
  220.     {
  221.         $this->end_at $end_at;
  222.         return $this;
  223.     }
  224.     public function getCreatedAt(): ?\DateTimeImmutable
  225.     {
  226.         return $this->created_at;
  227.     }
  228.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  229.     {
  230.         $this->created_at $created_at;
  231.         return $this;
  232.     }
  233.     public function getCustomName(){
  234.         $this->customName $this->getId();
  235.     }
  236.     public function getForciblyCompleted(): ?bool
  237.     {
  238.         return $this->forcibly_completed;
  239.     }
  240.     public function setForciblyCompleted(?bool $forcibly_completed): self
  241.     {
  242.         $this->forcibly_completed $forcibly_completed;
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, Qualification>
  247.      */
  248.     public function getAssignedQualifications(): Collection
  249.     {
  250.         // use this
  251.         return new ArrayCollection$this->assigned_qualifications->map( function ( /**@var $qualification Qualification*/ $qualification ){
  252.             return $qualification;
  253.         })->getValues() );
  254.         // Instead of this
  255.         // return $this->assigned_qualifications;
  256.         // Info: If Assigned Q empty selected return, error for required field, if select again any value collection returned as associative array instead indexed
  257.     }
  258.     public function addAssignedQualification(Qualification $assignedQualification): self
  259.     {
  260.         if (!$this->assigned_qualifications->contains($assignedQualification)) {
  261.             $this->assigned_qualifications[] = $assignedQualification;
  262.         }
  263.         return $this;
  264.     }
  265.     public function removeAssignedQualification(Qualification $assignedQualification): self
  266.     {
  267.         $this->assigned_qualifications->removeElement($assignedQualification);
  268.         return $this;
  269.     }
  270.     public function getCostPerHour(): ?float
  271.     {
  272.         return $this->cost_per_hour;// ?? $this->getWorker()->getCostPerHour();
  273.     }
  274.     public function setCostPerHour(?string $cost_per_hour): self
  275.     {
  276.         $this->cost_per_hour $cost_per_hour;
  277.         return $this;
  278.     }
  279.     public function isCanAppCheckAnywhere(): ?bool
  280.     {
  281.         return $this->can_app_check_anywhere;
  282.     }
  283.     public function setCanAppCheckAnywhere(?bool $can_app_check_anywhere): self
  284.     {
  285.         $this->can_app_check_anywhere $can_app_check_anywhere;
  286.         return $this;
  287.     }
  288.     /**
  289.      * @return Collection<int, ProjectBranches>
  290.      */
  291.     public function getAssignedProjectBranches(): Collection
  292.     {
  293.         return $this->assigned_project_branches;
  294.     }
  295.     public function addAssignedProjectBranch(ProjectBranches $assignedProjectBranch): self
  296.     {
  297.         if (!$this->assigned_project_branches->contains($assignedProjectBranch)) {
  298.             $this->assigned_project_branches[] = $assignedProjectBranch;
  299.         }
  300.         return $this;
  301.     }
  302.     public function removeAssignedProjectBranch(ProjectBranches $assignedProjectBranch): self
  303.     {
  304.         $this->assigned_project_branches->removeElement($assignedProjectBranch);
  305.         return $this;
  306.     }
  307.     /**
  308.      * @return Collection<int, ProjectBranches>
  309.      */
  310.     public function getProjectBranchesTeamLeader(): Collection
  311.     {
  312.         return $this->project_branches_team_leader;
  313.     }
  314.     public function addProjectBranchesTeamLeader(ProjectBranches $workerInProjectProjectBranchesTeamLeader): self
  315.     {
  316.         if (!$this->project_branches_team_leader->contains($workerInProjectProjectBranchesTeamLeader)) {
  317.             $this->project_branches_team_leader[] = $workerInProjectProjectBranchesTeamLeader;
  318.         }
  319.         return $this;
  320.     }
  321.     public function removeProjectBranchesTeamLeader(ProjectBranches $workerInProjectProjectBranchesTeamLeader): self
  322.     {
  323.         $this->project_branches_team_leader->removeElement($workerInProjectProjectBranchesTeamLeader);
  324.         return $this;
  325.     }
  326.     public function getWorkerActivity(): ?WorkerActivities
  327.     {
  328.         return $this->worker_activity;
  329.     }
  330.     public function setWorkerActivity(?WorkerActivities $workerActivity): self
  331.     {
  332.         $this->worker_activity $workerActivity;
  333.         return $this;
  334.     }
  335. }