src/Entity/Provincia.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  9. /**
  10.  * Provincia
  11.  *
  12.  * @ORM\Table(name="provincia")
  13.   * @ORM\Entity(repositoryClass="App\Repository\ProvinciaRepository")
  14.  */
  15. class Provincia implements TranslatableInterface
  16. {
  17.     use TranslatableTrait;
  18.     
  19.     /**
  20.      * @var integer
  21.      *
  22.      * @ORM\Column(name="id", type="integer")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @var string
  29.      *
  30.      * @ORM\Column(name="nombre", type="string", length=100)
  31.      */
  32.     private $nombre;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\ManyToOne(targetEntity="Imagen") 
  37.      */
  38.     protected $imagenCabecera;  
  39.     /**
  40.      * @var string
  41.      *
  42.      * @ORM\ManyToOne(targetEntity="Imagen") 
  43.      */
  44.     protected $imagenBanner;  
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(name="gastos", type="string", length=255)
  49.      */
  50.     private $gastos;
  51.     /**
  52.      * @var integer
  53.      *
  54.      * @ORM\Column(name="peso", type="integer", nullable=false)
  55.      * @ORM\OrderBy({"peso" = "DESC"})
  56.      */
  57.     private $peso=0;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity="Localidad", mappedBy="provincia", fetch="EAGER")
  60.      * @ORM\OrderBy({"peso" = "DESC"})
  61.      */
  62.     private $localidades;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity="Oficina", mappedBy="provincia")
  65.      * @ORM\OrderBy({"peso" = "DESC"})
  66.      */
  67.     private $oficinas;
  68.     
  69.     public function __call($method$args)
  70.     {
  71.         //return $this->proxyCurrentLocaleTranslation($method, $arguments);
  72.         if (!method_exists(self::getTranslationEntityClass(), $method)) {
  73.             $method 'get'ucfirst($method);
  74.         }
  75.         return $this->proxyCurrentLocaleTranslation($method$args);        
  76.     }
  77.     public function __construct() {
  78.         $this->traducciones = new ArrayCollection();
  79.         $this->localidades = new ArrayCollection();
  80.         $this->oficinas = new ArrayCollection();
  81.     }
  82.     /**
  83.      * Get id
  84.      *
  85.      * @return integer
  86.      */
  87.     public function getId()
  88.     {
  89.         return $this->id;
  90.     }
  91.     /**
  92.      * Set nombre
  93.      *
  94.      * @param string $nombre
  95.      * @return Provincia
  96.      */
  97.     public function setNombre($nombre)
  98.     {
  99.         $this->nombre $nombre;
  100.         return $this;
  101.     }
  102.     /**
  103.      * Get nombre
  104.      *
  105.      * @return string
  106.      */
  107.     public function getNombre()
  108.     {
  109.         return $this->nombre;
  110.     }
  111.     /**
  112.      * Set gastos
  113.      *
  114.      * @param string $gastos
  115.      * @return Provincia
  116.      */
  117.     public function setGastos($gastos)
  118.     {
  119.         $this->gastos $gastos;
  120.         return $this;
  121.     }
  122.     /**
  123.      * Get gastos
  124.      *
  125.      * @return float
  126.      */
  127.     public function getGastos()
  128.     {
  129.         return $this->gastos;
  130.     }
  131.     public function __toString(){
  132.         return $this->nombre;
  133.     }
  134.     /**
  135.      * Set peso
  136.      *
  137.      * @param integer $peso
  138.      * @return Oficina
  139.      */
  140.     public function setPeso($peso)
  141.     {
  142.         $this->peso=$peso;
  143.         return $this;
  144.     }
  145.     /**
  146.      * Get peso
  147.      *
  148.      * @return integer
  149.      */
  150.     public function getPeso()
  151.     {
  152.         return $this->peso;
  153.     }
  154.     /**
  155.      * Set localidades
  156.      *
  157.      * @param ArrayCollection $localidades
  158.      * @return Oficina
  159.      */
  160.     public function setLocalidades($localidades)
  161.     {
  162.         $this->localidades=$localidades;
  163.         return $this;
  164.     }
  165.     /**
  166.      * Get localidades
  167.      *
  168.      * @return ArrayCollection
  169.      */
  170.     public function getLocalidades()
  171.     {
  172.         return $this->localidades;
  173.     }
  174.     /**
  175.      * Set oficinas
  176.      *
  177.      * @param ArrayCollection $oficinas
  178.      * @return ArrayCollection
  179.      */
  180.     public function setOficinas($oficinas)
  181.     {
  182.         $this->oficinas=$oficinas;
  183.         return $this;
  184.     }
  185.     /**
  186.      * Get oficinas
  187.      *
  188.      * @return integer
  189.      */
  190.     public function getOficinas()
  191.     {
  192.         return $this->oficinas;
  193.     }
  194.     public function getImagenCabecera(): ?Imagen
  195.     {
  196.         return $this->imagenCabecera;
  197.     }
  198.     public function setImagenCabecera(?Imagen $imagenCabecera): self
  199.     {
  200.         $this->imagenCabecera $imagenCabecera;
  201.         return $this;
  202.     }
  203.     public function getImagenBanner(): ?Imagen
  204.     {
  205.         return $this->imagenBanner;
  206.     }
  207.     public function setImagenBanner(?Imagen $imagenBanner): self
  208.     {
  209.         $this->imagenBanner $imagenBanner;
  210.         return $this;
  211.     }
  212.     public function addLocalidade(Localidad $localidade): self
  213.     {
  214.         if (!$this->localidades->contains($localidade)) {
  215.             $this->localidades->add($localidade);
  216.             $localidade->setProvincia($this);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeLocalidade(Localidad $localidade): self
  221.     {
  222.         if ($this->localidades->removeElement($localidade)) {
  223.             // set the owning side to null (unless already changed)
  224.             if ($localidade->getProvincia() === $this) {
  225.                 $localidade->setProvincia(null);
  226.             }
  227.         }
  228.         return $this;
  229.     }
  230.     public function addOficina(Oficina $oficina): self
  231.     {
  232.         if (!$this->oficinas->contains($oficina)) {
  233.             $this->oficinas->add($oficina);
  234.             $oficina->setProvincia($this);
  235.         }
  236.         return $this;
  237.     }
  238.     public function removeOficina(Oficina $oficina): self
  239.     {
  240.         if ($this->oficinas->removeElement($oficina)) {
  241.             // set the owning side to null (unless already changed)
  242.             if ($oficina->getProvincia() === $this) {
  243.                 $oficina->setProvincia(null);
  244.             }
  245.         }
  246.         return $this;
  247.     }
  248. }