src/Entity/Branches.php line 18

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\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Doctrine\ORM\Mapping\UniqueConstraint;
  9. /**
  10.  * @ORM\Entity(repositoryClass=BranchesRepository::class)
  11.  * @ORM\Table(name="branches", uniqueConstraints={
  12.  *          @UniqueConstraint(name="unique_branch_in_location", columns={"name", "branch_location_id"})
  13.  *     })
  14.  */
  15. class Branches
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      * @Groups({
  22.      *     "project.branches",
  23.      *     "branches.base",
  24.      *     "customer.selected.project",
  25.      *     "worker.manage.joined.projects",
  26.      *     "stakeholder.selected.core.project.manage",
  27.      *     "worker.manage.selected.worker.in.project",
  28.      *     "selected.customer.project.for.worker",
  29.      *
  30.      *     "branch.base",
  31.      *     "branch.core"
  32.      * })
  33.      */
  34.     private $id;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      * @Groups({
  38.      *     "project.branches",
  39.      *     "branches.base",
  40.      *     "customer.selected.project",
  41.      *     "worker.manage.joined.projects",
  42.      *     "stakeholder.selected.core.project.manage",
  43.      *     "worker.manage.selected.worker.in.project",
  44.      *     "selected.customer.project.for.worker",
  45.      *     "worker.manage.base.timesheet.payments",
  46.      *
  47.      *     "branch.base",
  48.      *     "branch.core"
  49.      * })
  50.      */
  51.     private $name;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=ProjectBranches::class, mappedBy="branch")
  54.      */
  55.     private $project_branches;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="branches")
  58.      * @ORM\JoinColumn(nullable=false)
  59.      * @Groups({
  60.      *     "project.branches",
  61.      *     "branches.location.base",
  62.      *     "customer.selected.project",
  63.      *     "branch.location",
  64.      * })
  65.      */
  66.     private $branch_location;
  67.     /**
  68.      * @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="order_branch")
  69.      */
  70.     private $project_orders;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=BranchDepartements::class, mappedBy="branch", cascade={"persist", "remove"})
  73.      * @Groups({
  74.      *      "branch.departements",
  75.      *  })
  76.      */
  77.     private $branch_departements;
  78.     /**
  79.      * @ORM\Column(type="datetime_immutable", nullable=true)
  80.      * @Groups({
  81.      *      "branch.core"
  82.      *  })
  83.      */
  84.     private $created_at;
  85.     public function __construct()
  86.     {
  87.         $this->project_branches = new ArrayCollection();
  88.         $this->project_orders = new ArrayCollection();
  89.         $this->branch_departements = new ArrayCollection();
  90.     }
  91.     public function getId(): ?int
  92.     {
  93.         return $this->id;
  94.     }
  95.     public function getName(): ?string
  96.     {
  97.         return $this->name;
  98.     }
  99.     public function setName(string $name): self
  100.     {
  101.         $this->name $name;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, ProjectBranches>
  106.      */
  107.     public function getProjectBranches(): Collection
  108.     {
  109.         return $this->project_branches;
  110.     }
  111.     public function addProjectDependentBranch(ProjectBranches $projectDependentBranch): self
  112.     {
  113.         if (!$this->project_branches->contains($projectDependentBranch)) {
  114.             $this->project_branches[] = $projectDependentBranch;
  115.             $projectDependentBranch->setBranch($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeProjectDependentBranch(ProjectBranches $projectDependentBranch): self
  120.     {
  121.         if ($this->project_branches->removeElement($projectDependentBranch)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($projectDependentBranch->getBranch() === $this) {
  124.                 $projectDependentBranch->setBranch(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129.     public function getBranchLocation(): ?Locations
  130.     {
  131.         return $this->branch_location;
  132.     }
  133.     public function setBranchLocation(?Locations $branch_location): self
  134.     {
  135.         $this->branch_location $branch_location;
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return Collection<int, ProjectOrders>
  140.      */
  141.     public function getProjectOrders(): Collection
  142.     {
  143.         return $this->project_orders;
  144.     }
  145.     public function addProjectOrder(ProjectOrders $projectOrder): self
  146.     {
  147.         if (!$this->project_orders->contains($projectOrder)) {
  148.             $this->project_orders[] = $projectOrder;
  149.             $projectOrder->setOrderBranch($this);
  150.         }
  151.         return $this;
  152.     }
  153.     public function removeProjectOrder(ProjectOrders $projectOrder): self
  154.     {
  155.         if ($this->project_orders->removeElement($projectOrder)) {
  156.             // set the owning side to null (unless already changed)
  157.             if ($projectOrder->getOrderBranch() === $this) {
  158.                 $projectOrder->setOrderBranch(null);
  159.             }
  160.         }
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return Collection<int, BranchDepartements>
  165.      */
  166.     public function getBranchDepartements(): Collection
  167.     {
  168.         return $this->branch_departements;
  169.     }
  170.     public function addBranchDepartement(BranchDepartements $branchDepartement): self
  171.     {
  172.         if (!$this->branch_departements->contains($branchDepartement)) {
  173.             $this->branch_departements[] = $branchDepartement;
  174.             $branchDepartement->setBranch($this);
  175.         }
  176.         return $this;
  177.     }
  178.     public function removeBranchDepartement(BranchDepartements $branchDepartement): self
  179.     {
  180.         if ($this->branch_departements->removeElement($branchDepartement)) {
  181.             // set the owning side to null (unless already changed)
  182.             if ($branchDepartement->getBranch() === $this) {
  183.                 $branchDepartement->setBranch(null);
  184.             }
  185.         }
  186.         return $this;
  187.     }
  188.     public function getCreatedAt(): ?\DateTimeImmutable
  189.     {
  190.         return $this->created_at;
  191.     }
  192.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  193.     {
  194.         $this->created_at $created_at;
  195.         return $this;
  196.     }
  197. }