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