<?php
namespace App\Entity;
use App\Repository\BranchesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping\UniqueConstraint;
/**
* @ORM\Entity(repositoryClass=BranchesRepository::class)
* @ORM\Table(name="branches", uniqueConstraints={
* @UniqueConstraint(name="unique_branch_in_location", columns={"name", "branch_location_id"})
* })
*/
class Branches
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "project.branches",
* "branches.base",
* "customer.selected.project",
* "worker.manage.joined.projects",
* "stakeholder.selected.core.project.manage",
* "worker.manage.selected.worker.in.project",
* "selected.customer.project.for.worker",
*
* "branch.base",
* "branch.core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "project.branches",
* "branches.base",
* "customer.selected.project",
* "worker.manage.joined.projects",
* "stakeholder.selected.core.project.manage",
* "worker.manage.selected.worker.in.project",
* "selected.customer.project.for.worker",
* "worker.manage.base.timesheet.payments",
*
* "branch.base",
* "branch.core"
* })
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=ProjectBranches::class, mappedBy="branch")
*/
private $project_branches;
/**
* @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="branches")
* @ORM\JoinColumn(nullable=false)
* @Groups({
* "project.branches",
* "branches.location.base",
* "customer.selected.project",
* "branch.location",
* })
*/
private $branch_location;
/**
* @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="order_branch")
*/
private $project_orders;
/**
* @ORM\OneToMany(targetEntity=BranchDepartements::class, mappedBy="branch", cascade={"persist", "remove"})
* @Groups({
* "branch.departements",
* })
*/
private $branch_departements;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "branch.core"
* })
*/
private $created_at;
public function __construct()
{
$this->project_branches = new ArrayCollection();
$this->project_orders = new ArrayCollection();
$this->branch_departements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, ProjectBranches>
*/
public function getProjectBranches(): Collection
{
return $this->project_branches;
}
public function addProjectDependentBranch(ProjectBranches $projectDependentBranch): self
{
if (!$this->project_branches->contains($projectDependentBranch)) {
$this->project_branches[] = $projectDependentBranch;
$projectDependentBranch->setBranch($this);
}
return $this;
}
public function removeProjectDependentBranch(ProjectBranches $projectDependentBranch): self
{
if ($this->project_branches->removeElement($projectDependentBranch)) {
// set the owning side to null (unless already changed)
if ($projectDependentBranch->getBranch() === $this) {
$projectDependentBranch->setBranch(null);
}
}
return $this;
}
public function getBranchLocation(): ?Locations
{
return $this->branch_location;
}
public function setBranchLocation(?Locations $branch_location): self
{
$this->branch_location = $branch_location;
return $this;
}
/**
* @return Collection<int, ProjectOrders>
*/
public function getProjectOrders(): Collection
{
return $this->project_orders;
}
public function addProjectOrder(ProjectOrders $projectOrder): self
{
if (!$this->project_orders->contains($projectOrder)) {
$this->project_orders[] = $projectOrder;
$projectOrder->setOrderBranch($this);
}
return $this;
}
public function removeProjectOrder(ProjectOrders $projectOrder): self
{
if ($this->project_orders->removeElement($projectOrder)) {
// set the owning side to null (unless already changed)
if ($projectOrder->getOrderBranch() === $this) {
$projectOrder->setOrderBranch(null);
}
}
return $this;
}
/**
* @return Collection<int, BranchDepartements>
*/
public function getBranchDepartements(): Collection
{
return $this->branch_departements;
}
public function addBranchDepartement(BranchDepartements $branchDepartement): self
{
if (!$this->branch_departements->contains($branchDepartement)) {
$this->branch_departements[] = $branchDepartement;
$branchDepartement->setBranch($this);
}
return $this;
}
public function removeBranchDepartement(BranchDepartements $branchDepartement): self
{
if ($this->branch_departements->removeElement($branchDepartement)) {
// set the owning side to null (unless already changed)
if ($branchDepartement->getBranch() === $this) {
$branchDepartement->setBranch(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
}