src/Entity/Branches.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BranchesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\Selectable;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Doctrine\ORM\Mapping\UniqueConstraint;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. /**
  12.  * @ORM\Entity(repositoryClass=BranchesRepository::class)
  13.  * @ORM\Table(name="branches", uniqueConstraints={
  14.  *          @UniqueConstraint(name="unique_branch_in_location", columns={"name", "branch_location_id"})
  15.  *     })
  16.  * @UniqueEntity(
  17.  *       fields={"name", "branch_location"},
  18.  *       message="Branch already registered|Branch with combination (%s %s) is already registered"
  19.  *  )
  20.  */
  21. class Branches
  22. {
  23.     /**
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue
  26.      * @ORM\Column(type="integer")
  27.      * @Groups({
  28.      *     "project.branches",
  29.      *     "branches.base",
  30.      *     "partner.selected.project",
  31.      *     "worker.manage.joined.projects",
  32.      *     "stakeholder.selected.core.project.manage",
  33.      *     "worker.manage.selected.worker.in.project",
  34.      *     "selected.partner.project.for.worker",
  35.      *
  36.      *     "branch.base",
  37.      *     "branch.core",
  38.      *
  39.      *     "branch@core",
  40.      *     "branch@base"
  41.      *
  42.      * })
  43.      */
  44.     private $id;
  45.     /**
  46.      * @ORM\Column(type="string", length=255)
  47.      * @Groups({
  48.      *     "project.branches",
  49.      *     "branches.base",
  50.      *     "partner.selected.project",
  51.      *     "worker.manage.joined.projects",
  52.      *     "stakeholder.selected.core.project.manage",
  53.      *     "worker.manage.selected.worker.in.project",
  54.      *     "selected.partner.project.for.worker",
  55.      *     "worker.manage.base.timesheet.payments",
  56.      *
  57.      *     "branch.base",
  58.      *     "branch.core",
  59.      *     "branch@core",
  60.      *     "branch@base"
  61.      * })
  62.      */
  63.     private $name;
  64.     /**
  65.      *
  66.      * ❌❌❌❌❌❌❌❌
  67.      * @deprecated use Connect to direct Project
  68.      * @ORM\OneToMany(targetEntity=ProjectBranches::class, mappedBy="branch")
  69.      */
  70.     private $project_branches;
  71.     /**
  72.      * ✅✅✅✅✅✅✅✅
  73.      * @ORM\ManyToMany(targetEntity=Projects::class, mappedBy="branches")
  74.      */
  75.     private $projects;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="branches")
  78.      * @ORM\JoinColumn(nullable=false)
  79.      * @Groups({
  80.      *     "project.branches",
  81.      *     "branches.location.base",
  82.      *     "partner.selected.project",
  83.      *     "branch.location",
  84.      *
  85.      *     "branch@location"
  86.      * })
  87.      */
  88.     private $branch_location;
  89.     /**
  90.      * @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="order_branch")
  91.      */
  92.     private $project_orders;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity=BranchDepartments::class, mappedBy="branch", cascade={"persist", "remove"})
  95.      * @Groups({
  96.      *     "branch.departments",
  97.      *
  98.      *     "branch@departments"
  99.      *  })
  100.      */
  101.     private $branch_departments;
  102.     /**
  103.      * @ORM\Column(type="datetime_immutable", nullable=true)
  104.      * @Groups({
  105.      *     "branch.core",
  106.      *
  107.      *     "branch@core"
  108.      *  })
  109.      */
  110.     private $created_at;
  111.     /**
  112.      * @ORM\ManyToMany(targetEntity=WorkerInProject::class, mappedBy="branches")
  113.      * @Groups({
  114.      *     "branch@worker_in_projects"
  115.      * })
  116.      */
  117.     private $worker_in_projects;
  118.     /**
  119.      * @ORM\ManyToMany(targetEntity=WorkerInProject::class, mappedBy="project_branch_team_leader")
  120.      */
  121.     private $worker_in_project_team_leader;
  122.     /**
  123.      * @ORM\OneToMany(targetEntity=ProjectOrderTaskFulfillment::class, mappedBy="branch")
  124.      */
  125.     private $project_order_task_fulfillments;
  126.     public function __construct()
  127.     {
  128.         $this->project_branches = new ArrayCollection();
  129.         $this->project_orders = new ArrayCollection();
  130.         $this->branch_departments = new ArrayCollection();
  131.         $this->projects = new ArrayCollection();
  132.         $this->worker_in_projects = new ArrayCollection();
  133.         $this->worker_in_project_team_leader = new ArrayCollection();
  134.         $this->project_order_task_fulfillments = new ArrayCollection();
  135.     }
  136.     public function getId(): ?int
  137.     {
  138.         return $this->id;
  139.     }
  140.     public function getName(): ?string
  141.     {
  142.         return $this->name;
  143.     }
  144.     public function setName(string $name): self
  145.     {
  146.         $this->name $name;
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, ProjectBranches>
  151.      */
  152.     public function getProjectBranches(): Collection
  153.     {
  154.         return $this->project_branches;
  155.     }
  156.     public function addProjectDependentBranch(ProjectBranches $projectDependentBranch): self
  157.     {
  158.         if (!$this->project_branches->contains($projectDependentBranch)) {
  159.             $this->project_branches[] = $projectDependentBranch;
  160.             $projectDependentBranch->setBranch($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeProjectDependentBranch(ProjectBranches $projectDependentBranch): self
  165.     {
  166.         if ($this->project_branches->removeElement($projectDependentBranch)) {
  167.             // set the owning side to null (unless already changed)
  168.             if ($projectDependentBranch->getBranch() === $this) {
  169.                 $projectDependentBranch->setBranch(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174.     public function getBranchLocation(): ?Locations
  175.     {
  176.         return $this->branch_location;
  177.     }
  178.     public function setBranchLocation(?Locations $branch_location): self
  179.     {
  180.         $this->branch_location $branch_location;
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection<int, ProjectOrders>
  185.      */
  186.     public function getProjectOrders(): Collection
  187.     {
  188.         return $this->project_orders;
  189.     }
  190.     public function addProjectOrder(ProjectOrders $projectOrder): self
  191.     {
  192.         if (!$this->project_orders->contains($projectOrder)) {
  193.             $this->project_orders[] = $projectOrder;
  194.             $projectOrder->setOrderBranch($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeProjectOrder(ProjectOrders $projectOrder): self
  199.     {
  200.         if ($this->project_orders->removeElement($projectOrder)) {
  201.             // set the owning side to null (unless already changed)
  202.             if ($projectOrder->getOrderBranch() === $this) {
  203.                 $projectOrder->setOrderBranch(null);
  204.             }
  205.         }
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return Collection<int, BranchDepartments> & Selectable
  210.      */
  211.     public function getBranchDepartments(): Collection
  212.     {
  213.         return $this->branch_departments;
  214.     }
  215.     public function addBranchDepartment(BranchDepartments $branchDepartment): self
  216.     {
  217.         if (!$this->branch_departments->contains($branchDepartment)) {
  218.             $this->branch_departments[] = $branchDepartment;
  219.             $branchDepartment->setBranch($this);
  220.         }
  221.         return $this;
  222.     }
  223.     public function removeBranchDepartment(BranchDepartments $branchDepartment): self
  224.     {
  225.         if ($this->branch_departments->removeElement($branchDepartment)) {
  226.             // set the owning side to null (unless already changed)
  227.             if ($branchDepartment->getBranch() === $this) {
  228.                 $branchDepartment->setBranch(null);
  229.             }
  230.         }
  231.         return $this;
  232.     }
  233.     public function getCreatedAt(): ?\DateTimeImmutable
  234.     {
  235.         return $this->created_at;
  236.     }
  237.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  238.     {
  239.         $this->created_at $created_at;
  240.         return $this;
  241.     }
  242.     /**
  243.      * @return Collection<int, Projects>
  244.      */
  245.     public function getProjects(): Collection
  246.     {
  247.         return $this->projects;
  248.     }
  249.     public function addProject(Projects $project): self
  250.     {
  251.         if (!$this->projects->contains($project)) {
  252.             $this->projects[] = $project;
  253.             $project->addBranch($this);
  254.         }
  255.         return $this;
  256.     }
  257.     public function removeProject(Projects $project): self
  258.     {
  259.         if ($this->projects->removeElement($project)) {
  260.             $project->removeBranch($this);
  261.         }
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, WorkerInProject>
  266.      */
  267.     public function getWorkerInprojects(): Collection
  268.     {
  269.         return $this->worker_in_projects;
  270.     }
  271.     public function addWorkerInProject(WorkerInProject $workerInProject): self
  272.     {
  273.         if (!$this->worker_in_projects->contains($workerInProject)) {
  274.             $this->worker_in_projects[] = $workerInProject;
  275.             $workerInProject->addBranch($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeWorkerInProject(WorkerInProject $workerInProject): self
  280.     {
  281.         if ($this->worker_in_projects->removeElement($workerInProject)) {
  282.             $workerInProject->removeBranch($this);
  283.         }
  284.         return $this;
  285.     }
  286.     /**
  287.      * @return Collection<int, WorkerInProject>
  288.      */
  289.     public function getWorkerInProjectTeamLeader(): Collection
  290.     {
  291.         return $this->worker_in_project_team_leader;
  292.     }
  293.     public function addWorkerInProjectTeamLeader(WorkerInProject $workerInProjectTeamLeader): self
  294.     {
  295.         if (!$this->worker_in_project_team_leader->contains($workerInProjectTeamLeader)) {
  296.             $this->worker_in_project_team_leader[] = $workerInProjectTeamLeader;
  297.             $workerInProjectTeamLeader->addProjectBranchTeamLeader($this);
  298.         }
  299.         return $this;
  300.     }
  301.     public function removeWorkerInProjectTeamLeader(WorkerInProject $workerInProjectTeamLeader): self
  302.     {
  303.         if ($this->worker_in_project_team_leader->removeElement($workerInProjectTeamLeader)) {
  304.             $workerInProjectTeamLeader->removeProjectBranchTeamLeader($this);
  305.         }
  306.         return $this;
  307.     }
  308.     /**
  309.      * @return Collection<int, ProjectOrderTaskFulfillment>
  310.      */
  311.     public function getProjectOrderTaskFulfillments(): Collection
  312.     {
  313.         return $this->project_order_task_fulfillments;
  314.     }
  315.     public function addProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
  316.     {
  317.         if (!$this->project_order_task_fulfillments->contains($projectOrderTaskFulfillment)) {
  318.             $this->project_order_task_fulfillments[] = $projectOrderTaskFulfillment;
  319.             $projectOrderTaskFulfillment->setBranch($this);
  320.         }
  321.         return $this;
  322.     }
  323.     public function removeProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
  324.     {
  325.         if ($this->project_order_task_fulfillments->removeElement($projectOrderTaskFulfillment)) {
  326.             // set the owning side to null (unless already changed)
  327.             if ($projectOrderTaskFulfillment->getBranch() === $this) {
  328.                 $projectOrderTaskFulfillment->setBranch(null);
  329.             }
  330.         }
  331.         return $this;
  332.     }
  333. }