src/Entity/Division.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * Division
  8.  *
  9.  * @ORM\Table(name="division")
  10.  * @ORM\Entity
  11.  */
  12. class Division
  13. {
  14.     /**
  15.      * @var int
  16.      *
  17.      * @ORM\Column(name="id", type="integer", nullable=false)
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue(strategy="IDENTITY")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=199, unique=true)
  24.      */
  25.     private $intitule;
  26.     /**
  27.      * @var int
  28.      *
  29.      * @ORM\Column(name="gauche", type="integer", nullable=false)
  30.      */
  31.     private $gauche;
  32.     /**
  33.      * @var int
  34.      *
  35.      * @ORM\Column(name="droite", type="integer", nullable=false)
  36.      */
  37.     private $droite;
  38.     /**
  39.      * @var int|null
  40.      *
  41.      * @ORM\Column(name="niveau", type="integer", nullable=true)
  42.      */
  43.     private $niveau;
  44.     /**
  45.      * @var string
  46.      *
  47.      * @ORM\Column(name="libelle", type="string", length=100, nullable=false)
  48.      */
  49.     private $libelle;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity="App\Entity\Bureau", mappedBy="division")
  52.      */
  53.     private $bureaus;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="division", orphanRemoval=true)
  56.      */
  57.     private $users;
  58.  
  59.     /**
  60.      * @var \DateTime
  61.      * @ORM\Column(name="created_at", type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  62.      */
  63.     private $created_at;
  64.      /**
  65.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  66.      */
  67.     private $updated_at;
  68.     public function __construct()
  69.     {
  70.         $this->bureaus = new ArrayCollection();
  71.         $this->users = new ArrayCollection();
  72.         $this->created_at = new \DateTime();
  73.     }
  74.     
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.   
  80.     public function getGauche(): ?int
  81.     {
  82.         return $this->gauche;
  83.     }
  84.     public function setGauche(int $gauche): self
  85.     {
  86.         $this->gauche $gauche;
  87.         return $this;
  88.     }
  89.     public function getDroite(): ?int
  90.     {
  91.         return $this->droite;
  92.     }
  93.     public function setDroite(int $droite): self
  94.     {
  95.         $this->droite $droite;
  96.         return $this;
  97.     }
  98.     public function getNiveau(): ?int
  99.     {
  100.         return $this->niveau;
  101.     }
  102.     public function setNiveau(?int $niveau): self
  103.     {
  104.         $this->niveau $niveau;
  105.         return $this;
  106.     }
  107.     public function getIntitule(): ?string
  108.     {
  109.         return $this->intitule;
  110.     }
  111.     public function setIntitule(string $intitule): self
  112.     {
  113.         $this->intitule $intitule;
  114.         return $this;
  115.     }
  116.     public function getLibelle(): ?string
  117.     {
  118.         return $this->libelle;
  119.     }
  120.     public function setLibelle(string $libelle): self
  121.     {
  122.         $this->libelle $libelle;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return Collection|Bureau[]
  127.      */
  128.     public function getBureaus(): Collection
  129.     {
  130.         return $this->bureaus;
  131.     }
  132.     public function addBureau(Bureau $bureau): self
  133.     {
  134.         if (!$this->bureaus->contains($bureau)) {
  135.             $this->bureaus[] = $bureau;
  136.             $bureau->setDivision($this);
  137.         }
  138.         return $this;
  139.     }
  140.     public function removeBureau(Bureau $bureau): self
  141.     {
  142.         if ($this->bureaus->contains($bureau)) {
  143.             $this->bureaus->removeElement($bureau);
  144.             // set the owning side to null (unless already changed)
  145.             if ($bureau->getDivision() === $this) {
  146.                 $bureau->setDivision(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151.     public function __toString(){
  152.         return $this->getIntitule();
  153.     }
  154.     /**
  155.      * @return Collection|User[]
  156.      */
  157.     public function getUsers(): Collection
  158.     {
  159.         return $this->users;
  160.     }
  161.     public function addUser(User $user): self
  162.     {
  163.         if (!$this->users->contains($user)) {
  164.             $this->users[] = $user;
  165.             $user->setDivision($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeUser(User $user): self
  170.     {
  171.         if ($this->users->contains($user)) {
  172.             $this->users->removeElement($user);
  173.             // set the owning side to null (unless already changed)
  174.             if ($user->getDivision() === $this) {
  175.                 $user->setDivision(null);
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.     public function getCreated_at(): ?Datetime
  181.     {
  182.         return new \Datetime($this->created_at);
  183.     }
  184.     public function setCreated_at(Datetime $created_at): self
  185.     {
  186.         $this->created_at $created_at;
  187.         return $this;
  188.     }
  189.     /** 
  190.      * ORM\PreUpdate
  191.      */
  192.     public function updatedDate()
  193.     {
  194.         $this->setUpdated_at(new \Datetime);
  195.     }
  196.     public function setUpdated_at(\Datetime $updated_at)
  197.     {
  198.         $this->updated_at $updated_at;
  199.         return $this;
  200.     }
  201.     public function getUpdated_at()
  202.     {
  203.         return $this->updated_at;
  204.     }
  205. }