src/Entity/ProjectStakeholders.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectStakeholdersRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Event\LifecycleEventArgs;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Doctrine\ORM\Mapping\UniqueConstraint;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ORM\Entity(repositoryClass=ProjectStakeholdersRepository::class)
  13.  * UniqueEntity(
  14.  *      fields={"customer", "project", "start_at"},
  15.  *      errorPath="customer",
  16.  *      message="This customer already assigned to this project"
  17.  * )
  18.  *
  19.  * ORM\Table("project_stakeholders",
  20.  *     uniqueConstraints={UniqueConstraint(name="project_stakeholders_unique", columns={"customer_id", "project_id", "start_at", "end_at"}),
  21.  * })
  22.  * @ORM\Table(name="project_stakeholders", uniqueConstraints={
  23.  *     @UniqueConstraint(name="project_stakeholders_unique", columns={"customer_id", "project_id", "start_at", "end_at"})},
  24.  *     options={"comment": "Customer joined Project's table"}
  25.  * )
  26.  * ORM\Table(name="project_stakeholders", options={"comment": "Customer joined Project's table"})
  27.  * @ORM\HasLifecycleCallbacks
  28.  *
  29.  */
  30. class ProjectStakeholders
  31. {
  32.     /**
  33.      * IN Worker/Projects Component, Selectable Stakeholder Projects decide worker in stakeholder project or not
  34.      * This is a dynamic prop managed from
  35.      * CustomerController / fetchCustomerProjects
  36.      */
  37.     /**
  38.      * @Groups({
  39.      *     "worker.manage.selectable.stakeholder.projects"
  40.      * })
  41.      */
  42.     // private $is_in_included_to_project;
  43.     private $is_worker_included_to_project;
  44.     public function getIsWorkerIncludedToProject(){ return $this->is_worker_included_to_project;}
  45.     public function setIsWorkerIncludedToProject(string $is_in_included_to_project): self $this->is_worker_included_to_project $is_in_included_to_project; return $this;}
  46.     /**
  47.      * @ORM\Id
  48.      * @ORM\GeneratedValue
  49.      * @ORM\Column(type="integer")
  50.      * @Groups({"customer.joined.projects",
  51.      *     "customer.selected.project",
  52.      *     "worker.join.to.project",
  53.      *     "worker.manage.joined.projects",
  54.      *     "worker.manage.selectable.stakeholder.projects",
  55.      *     "selected.customer.project.for.worker",
  56.      *     "worker.manage.selected.worker.in.project",
  57.      *     "timesheet.for.customer"
  58.      * })
  59.      */
  60.     private $id;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="project_stakeholders")
  63.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  64.      */
  65.     private $customer;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=Projects::class, inversedBy="stakeholders")
  68.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  69.      * @Groups({"customer.joined.projects",
  70.      *     "customer.selected.project",
  71.      *     "worker.join.to.project",
  72.      *     "worker.manage.joined.projects",
  73.      *     "worker.manage.selectable.stakeholder.projects",
  74.      *     "worker.manage.selected.worker.in.project",
  75.      *     "selected.customer.project.for.worker",
  76.      *     "worker.manage.base.timesheet.payments",
  77.      *     "timesheet.for.customer"
  78.      * })
  79.      */
  80.     private $project;
  81.     /**
  82.      * @ORM\Column(type="datetime_immutable", nullable=true)
  83.      * @Groups({
  84.      *     "customer.joined.projects",
  85.      *     "customer.selected.project",
  86.      *     "worker.manage.joined.projects",
  87.      *     "selected.customer.project.for.worker",
  88.      *     "worker.manage.selected.worker.in.project"
  89.      * })
  90.      */
  91.     private $start_at;
  92.     /**
  93.      * @ORM\Column(type="datetime_immutable", nullable=true)
  94.      * @Groups({
  95.      *     "customer.joined.projects",
  96.      *     "customer.selected.project",
  97.      *     "worker.manage.joined.projects",
  98.      *     "selected.customer.project.for.worker",
  99.      *     "worker.manage.selected.worker.in.project"
  100.      * })
  101.      */
  102.     private $end_at;
  103.     /**
  104.      * @ORM\Column(type="datetime_immutable", nullable=true)
  105.      */
  106.     private $created_at;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity=WorkerInProject::class, mappedBy="project", cascade={"persist", "remove"})
  109.      * @ORM\JoinColumn(onDelete="CASCADE")
  110.      * @Groups({
  111.      *     "customer.manage.base",
  112.      *     "customer.selected.project",
  113.      *     "timesheet.for.stakeholder",
  114.      *     "timesheet.for.customer"
  115.      * })
  116.      */
  117.     /// TODO In react for frontend workerInProjects doesn't use so use worker_in_projects
  118.     /// Check This words in app
  119.     private $worker_in_projects;
  120.     /**
  121.      * ----------------------------------------------------------------------------------------------------------------
  122.      * This is custom column not associated to table
  123.      * Event Listener Prop
  124.      * This prop Update during event.listener
  125.      * @Groups({
  126.      *     "customer.joined.projects",
  127.      *     "customer.selected.project",
  128.      *     "worker.manage.joined.projects",
  129.      *     "worker.manage.selectable.stakeholder.projects",
  130.      *     "selected.customer.project.for.worker",
  131.      *     "worker.manage.selected.worker.in.project"
  132.      * })
  133.     */
  134.     private $status;
  135.     /**
  136.      * Event Listener Prop
  137.      * This prop Update during event.listener
  138.      * @param array $status
  139.      */
  140.     public function setStatus( array $status ): void {
  141.         $this->status $status;
  142.     }
  143.     /** * Event Listener Prop */
  144.     public function getStatus(){
  145.         return $this->status;
  146.     }
  147.     // ----------------------------------------------------------------------------------------------------------------
  148.     /**
  149.      * @ORM\ManyToMany(targetEntity=Qualification::class, inversedBy="projectStakeholders", cascade={"persist"})
  150.      * @ORM\JoinColumn(onDelete="CASCADE")
  151.      * @Groups({
  152.      *     "customer.joined.projects.depended.qualifications",
  153.      *     "selected.customer.project.for.worker",
  154.      *     "worker.manage.selected.worker.in.project"
  155.      * })
  156.      */
  157.     private $dependent_qualifications;
  158.     /**
  159.      * @ORM\ManyToMany(targetEntity=Certificates::class, inversedBy="projectStakeholders", cascade={"persist"}, fetch="EXTRA_LAZY")
  160.      * @ORM\JoinColumn(onDelete="CASCADE")
  161.      * @Groups({
  162.      *     "customer.joined.projects.depended.certificates",
  163.      *     "customer.joined.projects.depended.certificates.eligibility",
  164.      *     "worker.manage.selected.worker.in.project",
  165.      *     "selected.customer.project.for.worker"
  166.      * })
  167.      */
  168.     private $dependent_certificates;
  169.     /**
  170.      * @ORM\OneToMany(targetEntity=ProjectStakeholdersTimesheet::class, mappedBy="project_stakeholder", cascade={"persist", "remove"} )
  171.      * @ORM\JoinColumn(onDelete="CASCADE")
  172.      */
  173.     private $projectStakeholdersTimesheets;
  174.     /**
  175.      * @ORM\OneToMany(targetEntity=WorkerTimesheetPayments::class, mappedBy="project_stakeholder")
  176.      */
  177.     private $workerTimesheetPayments;
  178.     public function __construct()
  179.     {
  180.         $this->workerInProjects = new ArrayCollection();
  181.         $this->dependent_qualifications = new ArrayCollection();
  182.         $this->dependent_certificates = new ArrayCollection();
  183.         // $this->workerTimesheets = new ArrayCollection();
  184.         $this->projectStakeholdersTimesheets = new ArrayCollection();
  185.         $this->workerTimesheetPayments = new ArrayCollection();
  186.     }
  187.     public function getId(): ?int
  188.     {
  189.         return $this->id;
  190.     }
  191.     public function getCustomer(): ?Customer
  192.     {
  193.         return $this->customer;
  194.     }
  195.     public function setCustomer(?Customer $customer): self
  196.     {
  197.         $this->customer $customer;
  198.         return $this;
  199.     }
  200.     public function getProject(): ?Projects
  201.     {
  202.         return $this->project;
  203.     }
  204.     public function setProject(?Projects $project): self
  205.     {
  206.         $this->project $project;
  207.         return $this;
  208.     }
  209.     public function getStartAt(): ?\DateTimeImmutable
  210.     {
  211.         return $this->start_at;
  212.     }
  213.     public function setStartAt(?\DateTimeImmutable $start_at): self
  214.     {
  215.         $this->start_at $start_at;
  216.         return $this;
  217.     }
  218.     public function getEndAt(): ?\DateTimeImmutable
  219.     {
  220.         return $this->end_at;
  221.     }
  222.     public function setEndAt(?\DateTimeImmutable $end_at): self
  223.     {
  224.         $this->end_at $end_at;
  225.         return $this;
  226.     }
  227.     public function getCreatedAt(): ?\DateTimeImmutable
  228.     {
  229.         return $this->created_at;
  230.     }
  231.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  232.     {
  233.         $this->created_at $created_at;
  234.         return $this;
  235.     }
  236.     /**
  237.      * @return Collection<int, WorkerInProject>
  238.      */
  239.     public function getWorkerInProjects(): Collection
  240.     {
  241.         return $this->worker_in_projects;
  242.     }
  243.     public function addWorkerInProject(WorkerInProject $workerInProject): self
  244.     {
  245.         if (!$this->worker_in_projects->contains($workerInProject)) {
  246.             $this->worker_in_projects[] = $workerInProject;
  247.             $workerInProject->setProject($this);
  248.         }
  249.         return $this;
  250.     }
  251.     public function removeWorkerInProject(WorkerInProject $workerInProject): self
  252.     {
  253.         if ($this->worker_in_projects->removeElement($workerInProject)) {
  254.             // set the owning side to null (unless already changed)
  255.             if ($workerInProject->getProject() === $this) {
  256.                 $workerInProject->setProject(null);
  257.             }
  258.         }
  259.         return $this;
  260.     }
  261.     /**
  262.      * @return Collection<int, Qualification>
  263.      */
  264.     public function getDependentQualifications(): Collection
  265.     {
  266.         return $this->dependent_qualifications;
  267.     }
  268.     public function addDependentQualification(Qualification $dependentQualification): self
  269.     {
  270.         if (!$this->dependent_qualifications->contains($dependentQualification)) {
  271.             $this->dependent_qualifications[] = $dependentQualification;
  272.         }
  273.         return $this;
  274.     }
  275.     public function removeDependentQualification(Qualification $dependentQualification): self
  276.     {
  277.         $this->dependent_qualifications->removeElement($dependentQualification);
  278.         return $this;
  279.     }
  280.     /**
  281.      * @return Collection<int, Certificates>
  282.      */
  283.     public function getDependentCertificates(): Collection
  284.     {
  285.         return $this->dependent_certificates;
  286.     }
  287.     public function addDependentCertificate(Certificates $dependentCertificate): self
  288.     {
  289.         if (!$this->dependent_certificates->contains($dependentCertificate)) {
  290.             $this->dependent_certificates[] = $dependentCertificate;
  291.         }
  292.         return $this;
  293.     }
  294.     public function removeDependentCertificate(Certificates $dependentCertificate): self
  295.     {
  296.         $this->dependent_certificates->removeElement($dependentCertificate);
  297.         return $this;
  298.     }
  299.     //    /**
  300.     //     * @return Collection<int, WorkerTimesheet>
  301.     //     */
  302.     //    public function getWorkerTimesheets(): Collection
  303.     //    {
  304.     //        return $this->workerTimesheets;
  305.     //    }
  306.     //
  307.     //    public function addWorkerTimesheet(WorkerTimesheet $workerTimesheet): self
  308.     //    {
  309.     //        if (!$this->workerTimesheets->contains($workerTimesheet)) {
  310.     //            $this->workerTimesheets[] = $workerTimesheet;
  311.     //            $workerTimesheet->setProjectStakeholder($this);
  312.     //        }
  313.     //
  314.     //        return $this;
  315.     //    }
  316.     //
  317.     //    public function removeWorkerTimesheet(WorkerTimesheet $workerTimesheet): self
  318.     //    {
  319.     //        if ($this->workerTimesheets->removeElement($workerTimesheet)) {
  320.     //            // set the owning side to null (unless already changed)
  321.     //            if ($workerTimesheet->getProjectStakeholder() === $this) {
  322.     //                $workerTimesheet->setProjectStakeholder(null);
  323.     //            }
  324.     //        }
  325.     //
  326.     //        return $this;
  327.     //    }
  328.     /**
  329.      * @return Collection<int, ProjectStakeholdersTimesheet>
  330.      */
  331.     public function getProjectStakeholdersTimesheets(): Collection
  332.     {
  333.         return $this->projectStakeholdersTimesheets;
  334.     }
  335.     public function addProjectStakeholdersTimesheet(ProjectStakeholdersTimesheet $projectStakeholdersTimesheet): self
  336.     {
  337.         if (!$this->projectStakeholdersTimesheets->contains($projectStakeholdersTimesheet)) {
  338.             $this->projectStakeholdersTimesheets[] = $projectStakeholdersTimesheet;
  339.             $projectStakeholdersTimesheet->setProjectStakeholder($this);
  340.         }
  341.         return $this;
  342.     }
  343.     public function removeProjectStakeholdersTimesheet(ProjectStakeholdersTimesheet $projectStakeholdersTimesheet): self
  344.     {
  345.         if ($this->projectStakeholdersTimesheets->removeElement($projectStakeholdersTimesheet)) {
  346.             // set the owning side to null (unless already changed)
  347.             if ($projectStakeholdersTimesheet->getProjectStakeholder() === $this) {
  348.                 $projectStakeholdersTimesheet->setProjectStakeholder(null);
  349.             }
  350.         }
  351.         return $this;
  352.     }
  353.     /**
  354.      * @return Collection<int, WorkerTimesheetPayments>
  355.      */
  356.     public function getWorkerTimesheetPayments(): Collection
  357.     {
  358.         return $this->workerTimesheetPayments;
  359.     }
  360.     public function addWorkerTimesheetPayment(WorkerTimesheetPayments $workerTimesheetPayment): self
  361.     {
  362.         if (!$this->workerTimesheetPayments->contains($workerTimesheetPayment)) {
  363.             $this->workerTimesheetPayments[] = $workerTimesheetPayment;
  364.             $workerTimesheetPayment->setProjectStakeholder($this);
  365.         }
  366.         return $this;
  367.     }
  368.     public function removeWorkerTimesheetPayment(WorkerTimesheetPayments $workerTimesheetPayment): self
  369.     {
  370.         if ($this->workerTimesheetPayments->removeElement($workerTimesheetPayment)) {
  371.             // set the owning side to null (unless already changed)
  372.             if ($workerTimesheetPayment->getProjectStakeholder() === $this) {
  373.                 $workerTimesheetPayment->setProjectStakeholder(null);
  374.             }
  375.         }
  376.         return $this;
  377.     }
  378. }