<?php
namespace App\Entity;
use App\Repository\DependenciaRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity(repositoryClass=DependenciaRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class Dependencia
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $nombre;
/**
* @ORM\Column(type="boolean")
*/
private $estado;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $codigo;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $updated_at;
/**
* @ORM\OneToMany(targetEntity=PlanoCabecera::class, mappedBy="dependencia")
*/
private $planoCabeceras;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $tipo;
public function __construct()
{
$this->planoCabeceras = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getEstado(): ?bool
{
return $this->estado;
}
public function setEstado(bool $estado): self
{
$this->estado = $estado;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$dateTimeNow = new DateTime('now');
$this->setUpdatedAt($dateTimeNow);
if ($this->getCreatedAt() === null) {
$this->setCreatedAt($dateTimeNow);
}
}
/**
* @return Collection|PlanoCabecera[]
*/
public function getPlanoCabeceras(): Collection
{
return $this->planoCabeceras;
}
public function addPlanoCabecera(PlanoCabecera $planoCabecera): self
{
if (!$this->planoCabeceras->contains($planoCabecera)) {
$this->planoCabeceras[] = $planoCabecera;
$planoCabecera->setDependencia($this);
}
return $this;
}
public function removePlanoCabecera(PlanoCabecera $planoCabecera): self
{
if ($this->planoCabeceras->contains($planoCabecera)) {
$this->planoCabeceras->removeElement($planoCabecera);
// set the owning side to null (unless already changed)
if ($planoCabecera->getDependencia() === $this) {
$planoCabecera->setDependencia(null);
}
}
return $this;
}
public function __toString(){
// to show the name of the Category in the select
return $this->nombre;
// to show the id of the Category in the select
// return $this->id;
}
public function getCodigo(): ?int
{
return $this->codigo;
}
public function setCodigo(?int $codigo): self
{
$this->codigo = $codigo;
return $this;
}
public function getTipo(): ?int
{
return $this->tipo;
}
public function setTipo(?int $tipo): self
{
$this->tipo = $tipo;
return $this;
}
}