src/Entity/Localidad.php line 25
- <?php
- namespace App\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Symfony\Component\Validator\Constraints as Assert;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
- use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
- use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
- use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Localidad
- *
- * @ORM\Table(name="localidad")
- * @ORM\Entity
- */
- class Localidad implements TranslatableInterface//, SluggableInterface
- {
- use TranslatableTrait;
- //use SluggableTrait;
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string
- *
- * @ORM\Column(name="nombre", type="string", length=63)
- */
- private $nombre;
- /**
- * @ORM\ManyToOne(targetEntity="Provincia", inversedBy="localidades")
- * @ORM\JoinColumn(name="provincia", referencedColumnName="id", nullable=false)
- */
- private $provincia;
- private $nofis;
- /**
- * @var integer
- *
- * @ORM\Column(name="peso", type="integer", nullable=false)
- */
- private $peso=0;
- /**
- *
- * @ORM\OneToMany(targetEntity="Oficina", mappedBy="localidad", fetch="EXTRA_LAZY")
- * @ORM\OrderBy({"peso" = "DESC"})
- */
- private $oficinas;
- /**
- * @var string
- *
- * @ORM\Column(name="slug", type="string", length=255, nullable=true)
- */
- private $slug;
- public function getSluggableFields(): array
- {
- return ['nombre'];
- }
- public function __call($method, $args)
- {
- //return $this->proxyCurrentLocaleTranslation($method, $arguments);
- if (!method_exists(self::getTranslationEntityClass(), $method)) {
- $method = 'get'. ucfirst($method);
- }
- return $this->proxyCurrentLocaleTranslation($method, $args);
- }
- public function __toString() {
- return $this->nombre;
- }
- public function __construct() {
- $this->oficinas = new ArrayCollection();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set nombre
- *
- * @param string $nombre
- * @return Localidad
- */
- public function setNombre($nombre)
- {
- $this->nombre = $nombre;
- return $this;
- }
- /**
- * Get nombre
- *
- * @return string
- */
- public function getNombre()
- {
- return $this->nombre;
- }
- /**
- * Set provincia
- *
- * @param string $provincia
- * @return Localidad
- */
- public function setProvincia(Provincia $provincia)
- {
- $this->provincia = $provincia;
- return $this;
- }
- /**
- * Get provincia
- *
- * @return string
- */
- public function getProvincia()
- {
- return $this->provincia;
- }
- /**
- * Set peso
- *
- * @param integer $peso
- * @return Localidad
- */
- public function setPeso($peso)
- {
- $this->peso=$peso;
- return $this;
- }
- /**
- * Get peso
- *
- * @return integer
- */
- public function getPeso()
- {
- return $this->peso;
- }
- /**
- * Set nofis
- *
- * @param integer $nofis
- * @return Localidad
- */
- public function setNOfis($nofis)
- {
- $this->nofis=$nofis;
- return $this;
- }
- /**
- * Get nofis
- *
- * @return integer
- */
- public function getNofis()
- {
- return $this->oficinas->count();
- }
- /**
- * Set oficinas
- *
- * @param ArrayCollection $oficinas
- * @return ArrayCollection
- */
- public function setOficinas($oficinas)
- {
- $this->oficinas=$oficinas;
- return $this;
- }
- /**
- * Get oficinas
- *
- * @return integer
- */
- public function getOficinas()
- {
- return $this->oficinas;
- }
- public function getSlug(): ?string
- {
- return $this->slug;
- }
- public function setSlug(?string $slug): self
- {
- $this->slug = $slug;
- return $this;
- }
- public function addOficina(Oficina $oficina): self
- {
- if (!$this->oficinas->contains($oficina)) {
- $this->oficinas->add($oficina);
- $oficina->setLocalidad($this);
- }
- return $this;
- }
- public function removeOficina(Oficina $oficina): self
- {
- if ($this->oficinas->removeElement($oficina)) {
- // set the owning side to null (unless already changed)
- if ($oficina->getLocalidad() === $this) {
- $oficina->setLocalidad(null);
- }
- }
- return $this;
- }
- }