src/Entity/Provincia.php line 16

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