<?php
namespace App\Entity;
use App\Repository\BranchDepartmentsRepository;
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=BranchDepartmentsRepository::class)
* @ORM\Table(name="branch_departments", uniqueConstraints={
* @UniqueConstraint(name="unique_branch_departments", columns={"branch_id", "name"})
* })
*/
class BranchDepartments
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "branch.department.core",
*
* "branch_department@ref",
* "branch_department@core",
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Branches::class, inversedBy="branch_departments")
*/
private $branch;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "branch.department.core",
*
* "branch_department@ref",
* "branch_department@core",
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "branch.department.core",
*
* "branch_department@core",
* })
*/
private $description;
/**
* @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="branch_department")
*/
private $project_orders;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "branch.department.core",
*
* "branch_department@core",
* })
*/
private $created_at;
public function __construct()
{
$this->projectOrders = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getBranch(): ?Branches
{
return $this->branch;
}
public function setBranch(?Branches $branch): self
{
$this->branch = $branch;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, ProjectOrders>
*/
public function getProjectOrders(): Collection
{
return $this->projectOrders;
}
public function addProjectOrder(ProjectOrders $projectOrder): self
{
if (!$this->projectOrders->contains($projectOrder)) {
$this->projectOrders[] = $projectOrder;
$projectOrder->setBranchDepartment($this);
}
return $this;
}
public function removeProjectOrder(ProjectOrders $projectOrder): self
{
if ($this->projectOrders->removeElement($projectOrder)) {
// set the owning side to null (unless already changed)
if ($projectOrder->getBranchDepartment() === $this) {
$projectOrder->setBranchDepartment(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;
}
}