src/Entity/Provincia.php line 15

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