src/Entity/Cliente.php line 25

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\Intl\Countries;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. /**
  15.  * @ORM\Table(name="cliente", schema="perseo")
  16.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  17.  * @ORM\Entity(repositoryClass="App\Repository\ClienteRepository")
  18.  * @Vich\Uploadable
  19.  * @UniqueEntity("identificacion")
  20.  * @PerseoAssert\ContraintsValidarEntidadCp()
  21.  */
  22. class Cliente
  23. {
  24.     /**
  25.      * @ORM\Id
  26.      * @ORM\Column(type="bigint", options={"unsigned":true})
  27.      * @ORM\GeneratedValue(strategy="AUTO")
  28.      */
  29.     public $id;
  30.     /**
  31.      * @ORM\Column(type="string", nullable=true, name="razon_social")
  32.      */
  33.     protected $razonSocial;
  34.     /**
  35.      * @ORM\Column(type="string", nullable=true, name="alias")
  36.      */
  37.     protected $alias;
  38.     /**
  39.      * @ORM\Column(type="string", nullable=true, options={"comment":"DNI, Pasaporte, Licencia de Condución"})
  40.      */
  41.     protected $identificacionTipo;
  42.     /**
  43.      * @ORM\Column(type="string", nullable=true)
  44.      */
  45.     protected $identificacion;
  46.     /**
  47.      * @ORM\Column(type="string", nullable=true)
  48.      */
  49.     protected $direccion;
  50.     /**
  51.      * @ORM\Column(type="string", length=12, nullable=true)
  52.      * @Assert\Length(min = 5, max = 12)
  53.      */
  54.     protected $cp;
  55.     /**
  56.      * @ORM\Column(type="string", nullable=true)
  57.      */
  58.     protected $region;
  59.     /**
  60.      * @ORM\Column(type="string", nullable=true)
  61.      */
  62.     protected $ciudad;
  63.     /**
  64.      * @ORM\Column(type="string", nullable=true)
  65.      */
  66.     protected $telefono;
  67.     /**
  68.      * @ORM\Column(type="string", nullable=true)
  69.      */
  70.     protected $email;
  71.     /**
  72.      * @ORM\Column(type="string", nullable=true)
  73.      */
  74.     protected $identificacionFrontal;
  75.     /**
  76.      * @Vich\UploadableField(mapping="cliente", fileNameProperty="identificacionFrontal")
  77.      * @Assert\File(
  78.      *      maxSize = "15M",
  79.      *      mimeTypes = {
  80.      *          "image/jpeg",
  81.      *          "image/png",
  82.      *          "image/gif",
  83.      *          "image/webp",
  84.      *          "application/pdf"
  85.      *      },
  86.      *      mimeTypesMessage = "Solo se permiten imágenes (JPEG, PNG, GIF, WEBP) o archivos PDF."
  87.      *  )
  88.      * @var File
  89.      */
  90.     protected $identificacionFrontalFile;
  91.     /**
  92.      * @ORM\Column(type="string", nullable=true)
  93.      */
  94.     protected $identificacionTrasera;
  95.     /**
  96.      * @Vich\UploadableField(mapping="cliente", fileNameProperty="identificacionTrasera")
  97.      * @Assert\File(
  98.      *      maxSize = "15M",
  99.      *      mimeTypes = {
  100.      *          "image/jpeg",
  101.      *          "image/png",
  102.      *          "image/gif",
  103.      *          "image/webp",
  104.      *          "application/pdf"
  105.      *      },
  106.      *      mimeTypesMessage = "Solo se permiten imágenes (JPEG, PNG, GIF, WEBP) o archivos PDF."
  107.      *  )
  108.      * @var File
  109.      */
  110.     protected $identificacionTraseraFile;
  111.     /**
  112.      * @ORM\Column(type="string", length=2, nullable=true)
  113.      */
  114.     protected $idioma;
  115.     /**
  116.      * @ORM\Column(type="string", nullable=true, name="entidad_bancaria")
  117.      */
  118.     protected $entidadBancaria;
  119.     /**
  120.      * @ORM\Column(type="string", nullable=true)
  121.      */
  122.     protected $iban;
  123.     /**
  124.      * @ORM\Column(type="text", nullable=true)
  125.      */
  126.     protected $observaciones;
  127.     /**
  128.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  129.      */
  130.     protected $deletedAt;
  131.     /**
  132.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  133.      * @Gedmo\Timestampable(on="update")
  134.      */
  135.     protected $updatedAt;
  136.     /**
  137.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  138.      * @Gedmo\Timestampable(on="create")
  139.      */
  140.     protected $createdAt;
  141.     /**
  142.      * @ORM\Column(type="string", length=2, nullable=true, name="pais")
  143.      */
  144.     protected $pais;
  145.     /**
  146.      * @ORM\OneToOne(targetEntity="App\Entity\User", mappedBy="cliente")
  147.      */
  148.     protected $user;
  149.     /**
  150.      * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="cliente")
  151.      */
  152.     protected $valoraciones;
  153.     /**
  154.      * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="cliente")
  155.      */
  156.     private $actividades;
  157.     /**
  158.      * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="cliente")
  159.      */
  160.     protected $operaciones;
  161.     /*
  162.      * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="clientes")
  163.      * @ORM\JoinColumn(name="ciudad_id", referencedColumnName="id")
  164.      */
  165.     //protected $ciudad;
  166.     /**
  167.      * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="clientes")
  168.      * @ORM\JoinColumn(name="ccaa_id", referencedColumnName="id")
  169.      */
  170.     protected $ccaa;
  171.     /**
  172.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="clientes")
  173.      * @ORM\JoinColumn(name="provincia_id", referencedColumnName="id")
  174.      */
  175.     protected $provincia;
  176.     public function __construct()
  177.     {
  178.         $this->valoraciones = new ArrayCollection();
  179.         $this->operaciones = new ArrayCollection();
  180.         $this->actividades = new ArrayCollection();
  181.     }
  182.     public function __toString(): string
  183.     {
  184.         return $this->getRazonSocial() ? $this->getRazonSocial() : ($this->getUser() ? $this->getUser()?->getNombreCompleto() : '---');
  185.     }
  186.     public function getId(): ?string
  187.     {
  188.         return $this->id;
  189.     }
  190.     public function getRazonSocial(): ?string
  191.     {
  192.         return $this->razonSocial;
  193.     }
  194.     public function setRazonSocial(?string $razonSocial): self
  195.     {
  196.         $this->razonSocial $razonSocial;
  197.         return $this;
  198.     }
  199.     public function getAlias(): ?string
  200.     {
  201.         return $this->alias;
  202.     }
  203.     public function setAlias(?string $alias): self
  204.     {
  205.         $this->alias $alias;
  206.         return $this;
  207.     }
  208.     public function getIdentificacionTipo(): ?string
  209.     {
  210.         return $this->identificacionTipo;
  211.     }
  212.     public function setIdentificacionTipo(?string $identificacionTipo): self
  213.     {
  214.         $this->identificacionTipo $identificacionTipo;
  215.         return $this;
  216.     }
  217.     public function getIdentificacion(): ?string
  218.     {
  219.         return $this->identificacion;
  220.     }
  221.     public function setIdentificacion(?string $identificacion): self
  222.     {
  223.         $this->identificacion $identificacion;
  224.         return $this;
  225.     }
  226.     public function getIdentificacionFrontal(): ?string
  227.     {
  228.         return $this->identificacionFrontal;
  229.     }
  230.     public function setIdentificacionFrontal(?string $identificacionFrontal): self
  231.     {
  232.         $this->identificacionFrontal $identificacionFrontal;
  233.         return $this;
  234.     }
  235.     public function getIdentificacionFrontalFile(): ?File
  236.     {
  237.         return $this->identificacionFrontalFile;
  238.     }
  239.     public function setIdentificacionFrontalFile(?File $identificacionFrontalFile): self
  240.     {
  241.         $this->identificacionFrontalFile $identificacionFrontalFile;
  242.         if ($identificacionFrontalFile) {
  243.             // if 'updatedAt' is not defined in your entity, use another property
  244.             $this->setUpdatedAt(new \DateTime('now'));
  245.         }
  246.         return $this;
  247.     }
  248.     public function getIdentificacionTrasera(): ?string
  249.     {
  250.         return $this->identificacionTrasera;
  251.     }
  252.     public function setIdentificacionTrasera(?string $identificacionTrasera): self
  253.     {
  254.         $this->identificacionTrasera $identificacionTrasera;
  255.         return $this;
  256.     }
  257.     public function getIdentificacionTraseraFile(): ?File
  258.     {
  259.         return $this->identificacionTraseraFile;
  260.     }
  261.     public function setIdentificacionTraseraFile(?File $identificacionTraseraFile): self
  262.     {
  263.         $this->identificacionTraseraFile $identificacionTraseraFile;
  264.         if ($identificacionTraseraFile) {
  265.             // if 'updatedAt' is not defined in your entity, use another property
  266.             $this->setUpdatedAt(new \DateTime('now'));
  267.         }
  268.         return $this;
  269.     }
  270.     public function getIdioma(): ?string
  271.     {
  272.         return $this->idioma;
  273.     }
  274.     public function setIdioma(?string $idioma): self
  275.     {
  276.         $this->idioma $idioma;
  277.         return $this;
  278.     }
  279.     public function getEntidadBancaria(): ?string
  280.     {
  281.         return $this->entidadBancaria;
  282.     }
  283.     public function setEntidadBancaria(?string $entidadBancaria): self
  284.     {
  285.         $this->entidadBancaria $entidadBancaria;
  286.         return $this;
  287.     }
  288.     public function getIban(): ?string
  289.     {
  290.         return $this->iban;
  291.     }
  292.     public function setIban(?string $iban): self
  293.     {
  294.         $this->iban $iban;
  295.         return $this;
  296.     }
  297.     public function getObservaciones(): ?string
  298.     {
  299.         return $this->observaciones;
  300.     }
  301.     public function setObservaciones(?string $observaciones): self
  302.     {
  303.         $this->observaciones $observaciones;
  304.         return $this;
  305.     }
  306.     public function getDeletedAt(): ?\DateTimeInterface
  307.     {
  308.         return $this->deletedAt;
  309.     }
  310.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  311.     {
  312.         $this->deletedAt $deletedAt;
  313.         return $this;
  314.     }
  315.     public function getUpdatedAt(): ?\DateTimeInterface
  316.     {
  317.         return $this->updatedAt;
  318.     }
  319.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  320.     {
  321.         $this->updatedAt $updatedAt;
  322.         return $this;
  323.     }
  324.     public function getCreatedAt(): ?\DateTimeInterface
  325.     {
  326.         return $this->createdAt;
  327.     }
  328.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  329.     {
  330.         $this->createdAt $createdAt;
  331.         return $this;
  332.     }
  333.     public function getUser(): ?User
  334.     {
  335.         return $this->user;
  336.     }
  337.     public function setUser(?User $user): self
  338.     {
  339.         // unset the owning side of the relation if necessary
  340.         if ($user === null && $this->user !== null) {
  341.             $this->user->setCliente(null);
  342.         }
  343.         // set the owning side of the relation if necessary
  344.         if ($user !== null && $user->getCliente() !== $this) {
  345.             $user->setCliente($this);
  346.         }
  347.         $this->user $user;
  348.         return $this;
  349.     }
  350.     /**
  351.      * @return Collection|Valoracion[]
  352.      */
  353.     public function getValoraciones(): Collection
  354.     {
  355.         return $this->valoraciones;
  356.     }
  357.     public function addValoracione(Valoracion $valoracione): self
  358.     {
  359.         if (!$this->valoraciones->contains($valoracione)) {
  360.             $this->valoraciones[] = $valoracione;
  361.             $valoracione->setCliente($this);
  362.         }
  363.         return $this;
  364.     }
  365.     public function removeValoracione(Valoracion $valoracione): self
  366.     {
  367.         if ($this->valoraciones->removeElement($valoracione)) {
  368.             // set the owning side to null (unless already changed)
  369.             if ($valoracione->getCliente() === $this) {
  370.                 $valoracione->setCliente(null);
  371.             }
  372.         }
  373.         return $this;
  374.     }
  375.     /**
  376.      * @return Collection|Operacion[]
  377.      */
  378.     public function getOperaciones(): Collection
  379.     {
  380.         return $this->operaciones;
  381.     }
  382.     public function addOperacione(Operacion $operacione): self
  383.     {
  384.         if (!$this->operaciones->contains($operacione)) {
  385.             $this->operaciones[] = $operacione;
  386.             $operacione->setCliente($this);
  387.         }
  388.         return $this;
  389.     }
  390.     public function removeOperacione(Operacion $operacione): self
  391.     {
  392.         if ($this->operaciones->removeElement($operacione)) {
  393.             // set the owning side to null (unless already changed)
  394.             if ($operacione->getCliente() === $this) {
  395.                 $operacione->setCliente(null);
  396.             }
  397.         }
  398.         return $this;
  399.     }
  400.     public function getTelefono(): ?string
  401.     {
  402.         return $this->telefono;
  403.     }
  404.     public function setTelefono(?string $telefono): self
  405.     {
  406.         $this->telefono $telefono;
  407.         return $this;
  408.     }
  409.     public function getEmail(): ?string
  410.     {
  411.         return $this->email;
  412.     }
  413.     public function setEmail(?string $email): self
  414.     {
  415.         $this->email $email;
  416.         return $this;
  417.     }
  418.     public function getDireccion(): ?string
  419.     {
  420.         return $this->direccion;
  421.     }
  422.     public function setDireccion(?string $direccion): self
  423.     {
  424.         $this->direccion $direccion;
  425.         return $this;
  426.     }
  427.     public function getCp(): ?string
  428.     {
  429.         return $this->cp;
  430.     }
  431.     public function setCp(?string $cp): self
  432.     {
  433.         $this->cp $cp;
  434.         return $this;
  435.     }
  436.     public function getCiudad(): ?string
  437.     {
  438.         return $this->ciudad;
  439.     }
  440.     public function setCiudad(?string $ciudad): self
  441.     {
  442.         $this->ciudad $ciudad;
  443.         return $this;
  444.     }
  445.     public function getCcaa(): ?CCAA
  446.     {
  447.         return $this->ccaa;
  448.     }
  449.     public function setCcaa(?CCAA $ccaa): self
  450.     {
  451.         $this->ccaa $ccaa;
  452.         return $this;
  453.     }
  454.     public function getPais(): ?string
  455.     {
  456.         return $this->pais;
  457.     }
  458.     public function setPais(?string $pais): self
  459.     {
  460.         $this->pais $pais;
  461.         return $this;
  462.     }
  463.     public function getProvincia(): ?Provincia
  464.     {
  465.         return $this->provincia;
  466.     }
  467.     public function setProvincia(?Provincia $provincia): self
  468.     {
  469.         $this->provincia $provincia;
  470.         return $this;
  471.     }
  472.     /**
  473.      * @return Collection<int, ActividadAbstract>
  474.      */
  475.     public function getActividades(): Collection
  476.     {
  477.         return $this->actividades;
  478.     }
  479.     public function addActividade(ActividadAbstract $actividade): static
  480.     {
  481.         if (!$this->actividades->contains($actividade)) {
  482.             $this->actividades->add($actividade);
  483.             $actividade->setCliente($this);
  484.         }
  485.         return $this;
  486.     }
  487.     public function removeActividade(ActividadAbstract $actividade): static
  488.     {
  489.         if ($this->actividades->removeElement($actividade)) {
  490.             // set the owning side to null (unless already changed)
  491.             if ($actividade->getCliente() === $this) {
  492.                 $actividade->setCliente(null);
  493.             }
  494.         }
  495.         return $this;
  496.     }
  497.     public function getRegion(): ?string
  498.     {
  499.         return $this->region;
  500.     }
  501.     public function setRegion(?string $region): static
  502.     {
  503.         $this->region $region;
  504.         return $this;
  505.     }
  506.     public function getExportPais(): ?string
  507.     {
  508.         return $this->getPais() ? Countries::getName($this->getPais()) : null;
  509.     }
  510. }