src/Entity/Ciudad.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator as PerseoAssert;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\CiudadRepository")
  11.  * @ORM\Table(name="ciudad", schema="perseo")
  12.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  13.  * @PerseoAssert\ContraintsValidarEntidadCp()
  14.  */
  15. class Ciudad
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\Column(type="bigint")
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      */
  22.     protected $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=100, nullable=false)
  25.      * @Gedmo\Translatable
  26.      */
  27.     protected $nombre;
  28.     /**
  29.      * @ORM\Column(type="string", length=5, nullable=false)
  30.      * @Assert\Length(5)
  31.      */
  32.     protected $cp;
  33.     /**
  34.      * @ORM\Column(type="datetime", nullable=true)
  35.      */
  36.     protected $deletedAt;
  37.     /**
  38.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  39.      * @Gedmo\Timestampable(on="update")
  40.      */
  41.     protected $updatedAt;
  42.     /**
  43.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  44.      * @Gedmo\Timestampable(on="create")
  45.      */
  46.     protected $createdAt;
  47.     /**
  48.      * @ORM\Column(type="string", length=2, nullable=true, name="pais")
  49.      */
  50.     protected $pais;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="ciudad")
  53.      */
  54.     protected $user;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity="App\Entity\Cliente", mappedBy="ciudad")
  57.      */
  58.     protected $clientes;
  59.     /**
  60.      * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionFacturacionCiudad")
  61.      */
  62.     protected $direccionFacturacionCiudadVentas;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionEnvioCiudad")
  65.      */
  66.     protected $direccionEnvioCiudadVentas;
  67.     /**
  68.      * @ORM\OneToMany(targetEntity="App\Entity\Banco", mappedBy="ciudad")
  69.      */
  70.     protected $bancos;
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="ciudades")
  73.      * @ORM\JoinColumn(name="provincia_id", referencedColumnName="id")
  74.      */
  75.     protected $provincia;
  76.     public function __construct()
  77.     {
  78.         $this->user = new ArrayCollection();
  79.         $this->direccionFacturacionCiudadVentas = new ArrayCollection();
  80.         $this->direccionEnvioCiudadVentas = new ArrayCollection();
  81.         $this->bancos = new ArrayCollection();
  82.         $this->clientes = new ArrayCollection();
  83.     }
  84.     public function getId(): ?string
  85.     {
  86.         return $this->id;
  87.     }
  88.     public function getNombre(): ?string
  89.     {
  90.         return $this->nombre;
  91.     }
  92.     public function setNombre(string $nombre): self
  93.     {
  94.         $this->nombre $nombre;
  95.         return $this;
  96.     }
  97.     public function getCp(): ?string
  98.     {
  99.         return $this->cp;
  100.     }
  101.     public function setCp(string $cp): self
  102.     {
  103.         $this->cp $cp;
  104.         return $this;
  105.     }
  106.     public function getDeletedAt(): ?\DateTimeInterface
  107.     {
  108.         return $this->deletedAt;
  109.     }
  110.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  111.     {
  112.         $this->deletedAt $deletedAt;
  113.         return $this;
  114.     }
  115.     public function getUpdatedAt(): ?\DateTimeInterface
  116.     {
  117.         return $this->updatedAt;
  118.     }
  119.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  120.     {
  121.         $this->updatedAt $updatedAt;
  122.         return $this;
  123.     }
  124.     public function getCreatedAt(): ?\DateTimeInterface
  125.     {
  126.         return $this->createdAt;
  127.     }
  128.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  129.     {
  130.         $this->createdAt $createdAt;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection|User[]
  135.      */
  136.     public function getUser(): Collection
  137.     {
  138.         return $this->user;
  139.     }
  140.     public function addUser(User $user): self
  141.     {
  142.         if (!$this->user->contains($user)) {
  143.             $this->user[] = $user;
  144.             $user->setCiudad($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeUser(User $user): self
  149.     {
  150.         if ($this->user->removeElement($user)) {
  151.             // set the owning side to null (unless already changed)
  152.             if ($user->getCiudad() === $this) {
  153.                 $user->setCiudad(null);
  154.             }
  155.         }
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection|Venta[]
  160.      */
  161.     public function getDireccionFacturacionCiudadVentas(): Collection
  162.     {
  163.         return $this->direccionFacturacionCiudadVentas;
  164.     }
  165.     public function addDireccionFacturacionCiudadVenta(Venta $direccionFacturacionCiudadVenta): self
  166.     {
  167.         if (!$this->direccionFacturacionCiudadVentas->contains($direccionFacturacionCiudadVenta)) {
  168.             $this->direccionFacturacionCiudadVentas[] = $direccionFacturacionCiudadVenta;
  169.             $direccionFacturacionCiudadVenta->setDireccionFacturacionCiudad($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeDireccionFacturacionCiudadVenta(Venta $direccionFacturacionCiudadVenta): self
  174.     {
  175.         if ($this->direccionFacturacionCiudadVentas->removeElement($direccionFacturacionCiudadVenta)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($direccionFacturacionCiudadVenta->getDireccionFacturacionCiudad() === $this) {
  178.                 $direccionFacturacionCiudadVenta->setDireccionFacturacionCiudad(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection|Venta[]
  185.      */
  186.     public function getDireccionEnvioCiudadVentas(): Collection
  187.     {
  188.         return $this->direccionEnvioCiudadVentas;
  189.     }
  190.     public function addDireccionEnvioCiudadVenta(Venta $direccionEnvioCiudadVenta): self
  191.     {
  192.         if (!$this->direccionEnvioCiudadVentas->contains($direccionEnvioCiudadVenta)) {
  193.             $this->direccionEnvioCiudadVentas[] = $direccionEnvioCiudadVenta;
  194.             $direccionEnvioCiudadVenta->setDireccionEnvioCiudad($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeDireccionEnvioCiudadVenta(Venta $direccionEnvioCiudadVenta): self
  199.     {
  200.         if ($this->direccionEnvioCiudadVentas->removeElement($direccionEnvioCiudadVenta)) {
  201.             // set the owning side to null (unless already changed)
  202.             if ($direccionEnvioCiudadVenta->getDireccionEnvioCiudad() === $this) {
  203.                 $direccionEnvioCiudadVenta->setDireccionEnvioCiudad(null);
  204.             }
  205.         }
  206.         return $this;
  207.     }
  208.     public function getProvincia(): ?Provincia
  209.     {
  210.         return $this->provincia;
  211.     }
  212.     public function setProvincia(?Provincia $provincia): self
  213.     {
  214.         $this->provincia $provincia;
  215.         return $this;
  216.     }
  217.     public function getPais(): ?string
  218.     {
  219.         return $this->pais;
  220.     }
  221.     public function setPais(?string $pais): self
  222.     {
  223.         $this->pais $pais;
  224.         return $this;
  225.     }
  226.     /**
  227.      * @return Collection|Banco[]
  228.      */
  229.     public function getBancos(): Collection
  230.     {
  231.         return $this->bancos;
  232.     }
  233.     public function addBanco(Banco $banco): self
  234.     {
  235.         if (!$this->bancos->contains($banco)) {
  236.             $this->bancos[] = $banco;
  237.             $banco->setCiudad($this);
  238.         }
  239.         return $this;
  240.     }
  241.     public function removeBanco(Banco $banco): self
  242.     {
  243.         if ($this->bancos->removeElement($banco)) {
  244.             // set the owning side to null (unless already changed)
  245.             if ($banco->getCiudad() === $this) {
  246.                 $banco->setCiudad(null);
  247.             }
  248.         }
  249.         return $this;
  250.     }
  251.     /**
  252.      * @return Collection|Cliente[]
  253.      */
  254.     public function getClientes(): Collection
  255.     {
  256.         return $this->clientes;
  257.     }
  258.     public function addCliente(Cliente $cliente): self
  259.     {
  260.         if (!$this->clientes->contains($cliente)) {
  261.             $this->clientes[] = $cliente;
  262.             $cliente->setCiudad($this);
  263.         }
  264.         return $this;
  265.     }
  266.     public function removeCliente(Cliente $cliente): self
  267.     {
  268.         if ($this->clientes->removeElement($cliente)) {
  269.             // set the owning side to null (unless already changed)
  270.             if ($cliente->getCiudad() === $this) {
  271.                 $cliente->setCiudad(null);
  272.             }
  273.         }
  274.         return $this;
  275.     }
  276. }