<?php
namespace App\Entity;
use App\Repository\BranchDepartementsRepository;
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=BranchDepartementsRepository::class)
* @ORM\Table(name="branch_departements", uniqueConstraints={
* @UniqueConstraint(name="unique_branch_departements", columns={"branch_id", "name"})
* })
*/
class BranchDepartements
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "branch.departement.core"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Branches::class, inversedBy="branchDepartements")
*/
private $branch;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "branch.departement.core"
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "branch.departement.core"
* })
*/
private $description;
/**
* @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="branch_departement")
*/
private $projectOrders;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
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->setBranchDepartement($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->getBranchDepartement() === $this) {
$projectOrder->setBranchDepartement(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;
}
}