<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Division
*
* @ORM\Table(name="division")
* @ORM\Entity
*/
class Division
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="string", length=199, unique=true)
*/
private $intitule;
/**
* @var int
*
* @ORM\Column(name="gauche", type="integer", nullable=false)
*/
private $gauche;
/**
* @var int
*
* @ORM\Column(name="droite", type="integer", nullable=false)
*/
private $droite;
/**
* @var int|null
*
* @ORM\Column(name="niveau", type="integer", nullable=true)
*/
private $niveau;
/**
* @var string
*
* @ORM\Column(name="libelle", type="string", length=100, nullable=false)
*/
private $libelle;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Bureau", mappedBy="division")
*/
private $bureaus;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="division", orphanRemoval=true)
*/
private $users;
/**
* @var \DateTime
* @ORM\Column(name="created_at", type="datetime", options={"default": "CURRENT_TIMESTAMP"})
*/
private $created_at;
/**
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updated_at;
public function __construct()
{
$this->bureaus = new ArrayCollection();
$this->users = new ArrayCollection();
$this->created_at = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getGauche(): ?int
{
return $this->gauche;
}
public function setGauche(int $gauche): self
{
$this->gauche = $gauche;
return $this;
}
public function getDroite(): ?int
{
return $this->droite;
}
public function setDroite(int $droite): self
{
$this->droite = $droite;
return $this;
}
public function getNiveau(): ?int
{
return $this->niveau;
}
public function setNiveau(?int $niveau): self
{
$this->niveau = $niveau;
return $this;
}
public function getIntitule(): ?string
{
return $this->intitule;
}
public function setIntitule(string $intitule): self
{
$this->intitule = $intitule;
return $this;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
/**
* @return Collection|Bureau[]
*/
public function getBureaus(): Collection
{
return $this->bureaus;
}
public function addBureau(Bureau $bureau): self
{
if (!$this->bureaus->contains($bureau)) {
$this->bureaus[] = $bureau;
$bureau->setDivision($this);
}
return $this;
}
public function removeBureau(Bureau $bureau): self
{
if ($this->bureaus->contains($bureau)) {
$this->bureaus->removeElement($bureau);
// set the owning side to null (unless already changed)
if ($bureau->getDivision() === $this) {
$bureau->setDivision(null);
}
}
return $this;
}
public function __toString(){
return $this->getIntitule();
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setDivision($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
// set the owning side to null (unless already changed)
if ($user->getDivision() === $this) {
$user->setDivision(null);
}
}
return $this;
}
public function getCreated_at(): ?Datetime
{
return new \Datetime($this->created_at);
}
public function setCreated_at(Datetime $created_at): self
{
$this->created_at = $created_at;
return $this;
}
/**
* ORM\PreUpdate
*/
public function updatedDate()
{
$this->setUpdated_at(new \Datetime);
}
public function setUpdated_at(\Datetime $updated_at)
{
$this->updated_at = $updated_at;
return $this;
}
public function getUpdated_at()
{
return $this->updated_at;
}
}