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.     /**
  127.      * TaskExecution — bu lokasyonu (in-house) yoneten sorumlu kisi. Wizard Adim 5a'da
  128.      * otomatik onerilir; atanmamissa akis bloklanmaz (bkz. MODULE_SPECS/TaskExecution-Flow.md §2b).
  129.      * Bilerek tek yonlu (WorkerActivities tarafinda ters koleksiyon YOK) — bu iliski sadece
  130.      * "bu branch'in sorumlusu kim" sorusuna cevap verir, WorkerActivities'i sismesin.
  131.      * @ORM\ManyToOne(targetEntity=WorkerActivities::class)
  132.      * @ORM\JoinColumn(name="responsible_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  133.      * @Groups({
  134.      *     "branch@responsible"
  135.      * })
  136.      */
  137.     private $responsible;
  138.     public function __construct()
  139.     {
  140.         $this->project_branches = new ArrayCollection();
  141.         $this->project_orders = new ArrayCollection();
  142.         $this->branch_departments = new ArrayCollection();
  143.         $this->projects = new ArrayCollection();
  144.         $this->worker_in_projects = new ArrayCollection();
  145.         $this->worker_in_project_team_leader = new ArrayCollection();
  146.         $this->project_order_task_fulfillments = new ArrayCollection();
  147.     }
  148.     public function getId(): ?int
  149.     {
  150.         return $this->id;
  151.     }
  152.     public function getName(): ?string
  153.     {
  154.         return $this->name;
  155.     }
  156.     public function setName(string $name): self
  157.     {
  158.         $this->name $name;
  159.         return $this;
  160.     }
  161.     /**
  162.      * @return Collection<int, ProjectBranches>
  163.      */
  164.     public function getProjectBranches(): Collection
  165.     {
  166.         return $this->project_branches;
  167.     }
  168.     public function addProjectDependentBranch(ProjectBranches $projectDependentBranch): self
  169.     {
  170.         if (!$this->project_branches->contains($projectDependentBranch)) {
  171.             $this->project_branches[] = $projectDependentBranch;
  172.             $projectDependentBranch->setBranch($this);
  173.         }
  174.         return $this;
  175.     }
  176.     public function removeProjectDependentBranch(ProjectBranches $projectDependentBranch): self
  177.     {
  178.         if ($this->project_branches->removeElement($projectDependentBranch)) {
  179.             // set the owning side to null (unless already changed)
  180.             if ($projectDependentBranch->getBranch() === $this) {
  181.                 $projectDependentBranch->setBranch(null);
  182.             }
  183.         }
  184.         return $this;
  185.     }
  186.     public function getBranchLocation(): ?Locations
  187.     {
  188.         return $this->branch_location;
  189.     }
  190.     public function setBranchLocation(?Locations $branch_location): self
  191.     {
  192.         $this->branch_location $branch_location;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, ProjectOrders>
  197.      */
  198.     public function getProjectOrders(): Collection
  199.     {
  200.         return $this->project_orders;
  201.     }
  202.     public function addProjectOrder(ProjectOrders $projectOrder): self
  203.     {
  204.         if (!$this->project_orders->contains($projectOrder)) {
  205.             $this->project_orders[] = $projectOrder;
  206.             $projectOrder->setOrderBranch($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeProjectOrder(ProjectOrders $projectOrder): self
  211.     {
  212.         if ($this->project_orders->removeElement($projectOrder)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($projectOrder->getOrderBranch() === $this) {
  215.                 $projectOrder->setOrderBranch(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, BranchDepartments> & Selectable
  222.      */
  223.     public function getBranchDepartments(): Collection
  224.     {
  225.         return $this->branch_departments;
  226.     }
  227.     public function addBranchDepartment(BranchDepartments $branchDepartment): self
  228.     {
  229.         if (!$this->branch_departments->contains($branchDepartment)) {
  230.             $this->branch_departments[] = $branchDepartment;
  231.             $branchDepartment->setBranch($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeBranchDepartment(BranchDepartments $branchDepartment): self
  236.     {
  237.         if ($this->branch_departments->removeElement($branchDepartment)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($branchDepartment->getBranch() === $this) {
  240.                 $branchDepartment->setBranch(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     public function getCreatedAt(): ?\DateTimeImmutable
  246.     {
  247.         return $this->created_at;
  248.     }
  249.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  250.     {
  251.         $this->created_at $created_at;
  252.         return $this;
  253.     }
  254.     /**
  255.      * @return Collection<int, Projects>
  256.      */
  257.     public function getProjects(): Collection
  258.     {
  259.         return $this->projects;
  260.     }
  261.     public function addProject(Projects $project): self
  262.     {
  263.         if (!$this->projects->contains($project)) {
  264.             $this->projects[] = $project;
  265.             $project->addBranch($this);
  266.         }
  267.         return $this;
  268.     }
  269.     public function removeProject(Projects $project): self
  270.     {
  271.         if ($this->projects->removeElement($project)) {
  272.             $project->removeBranch($this);
  273.         }
  274.         return $this;
  275.     }
  276.     /**
  277.      * @return Collection<int, WorkerInProject>
  278.      */
  279.     public function getWorkerInprojects(): Collection
  280.     {
  281.         return $this->worker_in_projects;
  282.     }
  283.     public function addWorkerInProject(WorkerInProject $workerInProject): self
  284.     {
  285.         if (!$this->worker_in_projects->contains($workerInProject)) {
  286.             $this->worker_in_projects[] = $workerInProject;
  287.             $workerInProject->addBranch($this);
  288.         }
  289.         return $this;
  290.     }
  291.     public function removeWorkerInProject(WorkerInProject $workerInProject): self
  292.     {
  293.         if ($this->worker_in_projects->removeElement($workerInProject)) {
  294.             $workerInProject->removeBranch($this);
  295.         }
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, WorkerInProject>
  300.      */
  301.     public function getWorkerInProjectTeamLeader(): Collection
  302.     {
  303.         return $this->worker_in_project_team_leader;
  304.     }
  305.     public function addWorkerInProjectTeamLeader(WorkerInProject $workerInProjectTeamLeader): self
  306.     {
  307.         if (!$this->worker_in_project_team_leader->contains($workerInProjectTeamLeader)) {
  308.             $this->worker_in_project_team_leader[] = $workerInProjectTeamLeader;
  309.             $workerInProjectTeamLeader->addProjectBranchTeamLeader($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeWorkerInProjectTeamLeader(WorkerInProject $workerInProjectTeamLeader): self
  314.     {
  315.         if ($this->worker_in_project_team_leader->removeElement($workerInProjectTeamLeader)) {
  316.             $workerInProjectTeamLeader->removeProjectBranchTeamLeader($this);
  317.         }
  318.         return $this;
  319.     }
  320.     /**
  321.      * @return Collection<int, ProjectOrderTaskFulfillment>
  322.      */
  323.     public function getProjectOrderTaskFulfillments(): Collection
  324.     {
  325.         return $this->project_order_task_fulfillments;
  326.     }
  327.     public function addProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
  328.     {
  329.         if (!$this->project_order_task_fulfillments->contains($projectOrderTaskFulfillment)) {
  330.             $this->project_order_task_fulfillments[] = $projectOrderTaskFulfillment;
  331.             $projectOrderTaskFulfillment->setBranch($this);
  332.         }
  333.         return $this;
  334.     }
  335.     public function removeProjectOrderTaskFulfillment(ProjectOrderTaskFulfillment $projectOrderTaskFulfillment): self
  336.     {
  337.         if ($this->project_order_task_fulfillments->removeElement($projectOrderTaskFulfillment)) {
  338.             // set the owning side to null (unless already changed)
  339.             if ($projectOrderTaskFulfillment->getBranch() === $this) {
  340.                 $projectOrderTaskFulfillment->setBranch(null);
  341.             }
  342.         }
  343.         return $this;
  344.     }
  345.     public function getResponsible(): ?WorkerActivities
  346.     {
  347.         return $this->responsible;
  348.     }
  349.     public function setResponsible(?WorkerActivities $responsible): self
  350.     {
  351.         $this->responsible $responsible;
  352.         return $this;
  353.     }
  354. }