src/Entity/CCAA.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\CCAARepository")
  10.  * @ORM\Table(name="ccaa")
  11.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  12.  */
  13. class CCAA
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\Column(type="bigint")
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      * @JMS\Groups({
  20.      *       "api_v1_ccaa_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_ccaa_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\Column(type="string", length=2, nullable=true, name="pais")
  54.      */
  55.     protected $pais;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity="App\Entity\Provincia", mappedBy="ccaa")
  58.      */
  59.     protected $provincias;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="ccaa")
  62.      */
  63.     protected $user;
  64.     /**
  65.      * @ORM\OneToMany(targetEntity="App\Entity\Cliente", mappedBy="ccaa")
  66.      */
  67.     protected $clientes;
  68.     /**
  69.      * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionFacturacionCcaa")
  70.      */
  71.     protected $direccionFacturacionCcaaVentas;
  72.     /**
  73.      * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionEnvioCcaa")
  74.      */
  75.     protected $direccionEnvioCcaaVentas;
  76.     public function __construct()
  77.     {
  78.         $this->provincias = new ArrayCollection();
  79.         $this->user = new ArrayCollection();
  80.         $this->direccionFacturacionCcaaVentas = new ArrayCollection();
  81.         $this->direccionEnvioCcaaVentas = new ArrayCollection();
  82.         $this->clientes = new ArrayCollection();
  83.     }
  84.     public function __toString(): string
  85.     {
  86.         return $this->getNombre()??'---';
  87.     }
  88.     public function getId(): ?string
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getNombre(): ?string
  93.     {
  94.         return $this->nombre;
  95.     }
  96.     public function setNombre(string $nombre): self
  97.     {
  98.         $this->nombre $nombre;
  99.         return $this;
  100.     }
  101.     public function getDeletedAt(): ?\DateTimeInterface
  102.     {
  103.         return $this->deletedAt;
  104.     }
  105.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  106.     {
  107.         $this->deletedAt $deletedAt;
  108.         return $this;
  109.     }
  110.     public function getUpdatedAt(): ?\DateTimeInterface
  111.     {
  112.         return $this->updatedAt;
  113.     }
  114.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  115.     {
  116.         $this->updatedAt $updatedAt;
  117.         return $this;
  118.     }
  119.     public function getCreatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  124.     {
  125.         $this->createdAt $createdAt;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection|Provincia[]
  130.      */
  131.     public function getProvincias(): Collection
  132.     {
  133.         return $this->provincias;
  134.     }
  135.     public function addProvincia(Provincia $provincia): self
  136.     {
  137.         if (!$this->provincias->contains($provincia)) {
  138.             $this->provincias[] = $provincia;
  139.             $provincia->setCcaa($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeProvincia(Provincia $provincia): self
  144.     {
  145.         if ($this->provincias->removeElement($provincia)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($provincia->getCcaa() === $this) {
  148.                 $provincia->setCcaa(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return Collection|User[]
  155.      */
  156.     public function getUser(): Collection
  157.     {
  158.         return $this->user;
  159.     }
  160.     public function addUser(User $user): self
  161.     {
  162.         if (!$this->user->contains($user)) {
  163.             $this->user[] = $user;
  164.             $user->setCcaa($this);
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeUser(User $user): self
  169.     {
  170.         if ($this->user->removeElement($user)) {
  171.             // set the owning side to null (unless already changed)
  172.             if ($user->getCcaa() === $this) {
  173.                 $user->setCcaa(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return Collection|Venta[]
  180.      */
  181.     public function getDireccionFacturacionCcaaVentas(): Collection
  182.     {
  183.         return $this->direccionFacturacionCcaaVentas;
  184.     }
  185.     public function addDireccionFacturacionCcaaVenta(Venta $direccionFacturacionCcaaVenta): self
  186.     {
  187.         if (!$this->direccionFacturacionCcaaVentas->contains($direccionFacturacionCcaaVenta)) {
  188.             $this->direccionFacturacionCcaaVentas[] = $direccionFacturacionCcaaVenta;
  189.             $direccionFacturacionCcaaVenta->setDireccionFacturacionCcaa($this);
  190.         }
  191.         return $this;
  192.     }
  193.     public function removeDireccionFacturacionCcaaVenta(Venta $direccionFacturacionCcaaVenta): self
  194.     {
  195.         if ($this->direccionFacturacionCcaaVentas->removeElement($direccionFacturacionCcaaVenta)) {
  196.             // set the owning side to null (unless already changed)
  197.             if ($direccionFacturacionCcaaVenta->getDireccionFacturacionCcaa() === $this) {
  198.                 $direccionFacturacionCcaaVenta->setDireccionFacturacionCcaa(null);
  199.             }
  200.         }
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection|Venta[]
  205.      */
  206.     public function getDireccionEnvioCcaaVentas(): Collection
  207.     {
  208.         return $this->direccionEnvioCcaaVentas;
  209.     }
  210.     public function addDireccionEnvioCcaaVenta(Venta $direccionEnvioCcaaVenta): self
  211.     {
  212.         if (!$this->direccionEnvioCcaaVentas->contains($direccionEnvioCcaaVenta)) {
  213.             $this->direccionEnvioCcaaVentas[] = $direccionEnvioCcaaVenta;
  214.             $direccionEnvioCcaaVenta->setDireccionEnvioCcaa($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeDireccionEnvioCcaaVenta(Venta $direccionEnvioCcaaVenta): self
  219.     {
  220.         if ($this->direccionEnvioCcaaVentas->removeElement($direccionEnvioCcaaVenta)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($direccionEnvioCcaaVenta->getDireccionEnvioCcaa() === $this) {
  223.                 $direccionEnvioCcaaVenta->setDireccionEnvioCcaa(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228.     public function getPais(): ?string
  229.     {
  230.         return $this->pais;
  231.     }
  232.     public function setPais(?string $pais): self
  233.     {
  234.         $this->pais $pais;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection|Cliente[]
  239.      */
  240.     public function getClientes(): Collection
  241.     {
  242.         return $this->clientes;
  243.     }
  244.     public function addCliente(Cliente $cliente): self
  245.     {
  246.         if (!$this->clientes->contains($cliente)) {
  247.             $this->clientes[] = $cliente;
  248.             $cliente->setCcaa($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removeCliente(Cliente $cliente): self
  253.     {
  254.         if ($this->clientes->removeElement($cliente)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($cliente->getCcaa() === $this) {
  257.                 $cliente->setCcaa(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262. }