src/Entity/Dependencia.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DependenciaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use DateTime;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DependenciaRepository::class)
  10.  * @ORM\HasLifecycleCallbacks
  11.  */
  12. class Dependencia
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=100)
  22.      */
  23.     private $nombre;
  24.     /**
  25.      * @ORM\Column(type="boolean")
  26.      */
  27.     private $estado;
  28.     /**
  29.      * @ORM\Column(type="integer", nullable=true)
  30.      */
  31.     private $codigo;
  32.     
  33.     /**
  34.      * @ORM\Column(type="datetime")
  35.      */
  36.     
  37.     private $created_at;
  38.     /**
  39.      * @ORM\Column(type="datetime")
  40.      */
  41.     private $updated_at;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=PlanoCabecera::class, mappedBy="dependencia")
  44.      */
  45.     private $planoCabeceras;
  46.     /**
  47.      * @ORM\Column(type="integer", nullable=true)
  48.      */
  49.     private $tipo;
  50.     
  51.     public function __construct()
  52.     {
  53.         $this->planoCabeceras = new ArrayCollection();
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getNombre(): ?string
  60.     {
  61.         return $this->nombre;
  62.     }
  63.     public function setNombre(string $nombre): self
  64.     {
  65.         $this->nombre $nombre;
  66.         return $this;
  67.     }
  68.     public function getEstado(): ?bool
  69.     {
  70.         return $this->estado;
  71.     }
  72.     public function setEstado(bool $estado): self
  73.     {
  74.         $this->estado $estado;
  75.         return $this;
  76.     }
  77.     public function getCreatedAt(): ?\DateTimeInterface
  78.     {
  79.         return $this->created_at;
  80.     }
  81.     public function setCreatedAt(\DateTimeInterface $created_at): self
  82.     {
  83.         $this->created_at $created_at;
  84.         return $this;
  85.     }
  86.     public function getUpdatedAt(): ?\DateTimeInterface
  87.     {
  88.         return $this->updated_at;
  89.     }
  90.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  91.     {
  92.         $this->updated_at $updated_at;
  93.         return $this;
  94.     }
  95.     /**
  96.      * @ORM\PrePersist
  97.      * @ORM\PreUpdate
  98.      */
  99.     public function updatedTimestamps(): void
  100.     {
  101.         $dateTimeNow = new DateTime('now');
  102.         $this->setUpdatedAt($dateTimeNow);
  103.         if ($this->getCreatedAt() === null) {
  104.             $this->setCreatedAt($dateTimeNow);
  105.         }
  106.     }
  107.     /**
  108.      * @return Collection|PlanoCabecera[]
  109.      */
  110.     public function getPlanoCabeceras(): Collection
  111.     {
  112.         return $this->planoCabeceras;
  113.     }
  114.     public function addPlanoCabecera(PlanoCabecera $planoCabecera): self
  115.     {
  116.         if (!$this->planoCabeceras->contains($planoCabecera)) {
  117.             $this->planoCabeceras[] = $planoCabecera;
  118.             $planoCabecera->setDependencia($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removePlanoCabecera(PlanoCabecera $planoCabecera): self
  123.     {
  124.         if ($this->planoCabeceras->contains($planoCabecera)) {
  125.             $this->planoCabeceras->removeElement($planoCabecera);
  126.             // set the owning side to null (unless already changed)
  127.             if ($planoCabecera->getDependencia() === $this) {
  128.                 $planoCabecera->setDependencia(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     public function __toString(){
  134.         // to show the name of the Category in the select
  135.         return $this->nombre;
  136.         // to show the id of the Category in the select
  137.         // return $this->id;
  138.     }
  139.     public function getCodigo(): ?int
  140.     {
  141.         return $this->codigo;
  142.     }
  143.     public function setCodigo(?int $codigo): self
  144.     {
  145.         $this->codigo $codigo;
  146.         return $this;
  147.     }
  148.     public function getTipo(): ?int
  149.     {
  150.         return $this->tipo;
  151.     }
  152.     public function setTipo(?int $tipo): self
  153.     {
  154.         $this->tipo $tipo;
  155.         return $this;
  156.     }
  157. }