Estado.php 5.3 KB
<?php

namespace UBV\SurUbvBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * UBV\SurUbvBundle\Entity\Estado
 *
 * @ORM\Entity(repositoryClass="UBV\SurUbvBundle\Entity\EstadoRepository")
 * @ORM\Table(name="estado", indexes={@ORM\Index(name="fk_estado_pais1_idx", columns={"pais_id"})}, uniqueConstraints={@ORM\UniqueConstraint(name="id_estado_UNIQUE", columns={"id"})})
 */
class Estado
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @ORM\SequenceGenerator(sequenceName="estado_id_seq", allocationSize=1, initialValue=1)
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=50)
     */
    protected $descripcion;

    /**
     * @ORM\Column(type="string", length=6)
     */
    protected $codigo;

    /**
     * @ORM\OneToMany(targetEntity="Ciudad", mappedBy="estado")
     * @ORM\JoinColumn(name="id", referencedColumnName="estado_id", nullable=false)
     */
    protected $ciudads;

    /**
     * @ORM\OneToMany(targetEntity="Municipio", mappedBy="estado", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="id", referencedColumnName="estado_id", nullable=false)
     */
    protected $municipios;

    /**
     * @ORM\ManyToOne(targetEntity="Pais", inversedBy="estados")
     * @ORM\JoinColumn(name="pais_id", referencedColumnName="id", nullable=false)
     */
    protected $pais;
    
    /**
     * @ORM\OneToMany(targetEntity="Candidato", mappedBy="estado")
     * @ORM\JoinColumn(name="id", referencedColumnName="estado_id", nullable=false)
     */
    protected $candidatos;

    public function __construct()
    {
        $this->ciudads = new ArrayCollection();
        $this->municipios = new ArrayCollection();
        $this->candidatos = new ArrayCollection();
    }

    public function __sleep()
    {
        return array('id', 'descripcion', 'codigo', 'pais_id');
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set descripcion
     *
     * @param string $descripcion
     * @return Estado
     */
    public function setDescripcion($descripcion)
    {
        $this->descripcion = $descripcion;

        return $this;
    }

    /**
     * Get descripcion
     *
     * @return string 
     */
    public function getDescripcion()
    {
        return $this->descripcion;
    }

    /**
     * Set codigo
     *
     * @param string $codigo
     * @return Estado
     */
    public function setCodigo($codigo)
    {
        $this->codigo = $codigo;

        return $this;
    }

    /**
     * Get codigo
     *
     * @return string 
     */
    public function getCodigo()
    {
        return $this->codigo;
    }

    /**
     * Add ciudads
     *
     * @param \UBV\SurUbvBundle\Entity\Ciudad $ciudads
     * @return Estado
     */
    public function addCiudad(\UBV\SurUbvBundle\Entity\Ciudad $ciudads)
    {
        $this->ciudads[] = $ciudads;

        return $this;
    }

    /**
     * Remove ciudads
     *
     * @param \UBV\SurUbvBundle\Entity\Ciudad $ciudads
     */
    public function removeCiudad(\UBV\SurUbvBundle\Entity\Ciudad $ciudads)
    {
        $this->ciudads->removeElement($ciudads);
    }

    /**
     * Get ciudads
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getCiudads()
    {
        return $this->ciudads;
    }

    /**
     * Add municipios
     *
     * @param \UBV\SurUbvBundle\Entity\Municipio $municipios
     * @return Estado
     */
    public function addMunicipio(\UBV\SurUbvBundle\Entity\Municipio $municipios)
    {
        $this->municipios[] = $municipios;

        return $this;
    }

    /**
     * Remove municipios
     *
     * @param \UBV\SurUbvBundle\Entity\Municipio $municipios
     */
    public function removeMunicipio(\UBV\SurUbvBundle\Entity\Municipio $municipios)
    {
        $this->municipios->removeElement($municipios);
    }

    /**
     * Get municipios
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getMunicipios()
    {
        return $this->municipios;
    }

    /**
     * Set pais
     *
     * @param \UBV\SurUbvBundle\Entity\Pais $pais
     * @return Estado
     */
    public function setPais(\UBV\SurUbvBundle\Entity\Pais $pais)
    {
        $this->pais = $pais;

        return $this;
    }

    /**
     * Get pais
     *
     * @return \UBV\SurUbvBundle\Entity\Pais 
     */
    public function getPais()
    {
        return $this->pais;
    }
    
    public function __toString(){
      return $this->getDescripcion();
    }

    /**
     * Add candidatos
     *
     * @param \UBV\SurUbvBundle\Entity\Candidato $candidatos
     * @return Estado
     */
    public function addCandidato(\UBV\SurUbvBundle\Entity\Candidato $candidatos)
    {
        $this->candidatos[] = $candidatos;

        return $this;
    }

    /**
     * Remove candidatos
     *
     * @param \UBV\SurUbvBundle\Entity\Candidato $candidatos
     */
    public function removeCandidato(\UBV\SurUbvBundle\Entity\Candidato $candidatos)
    {
        $this->candidatos->removeElement($candidatos);
    }

    /**
     * Get candidatos
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getCandidatos()
    {
        return $this->candidatos;
    }
}