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")
  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="string", nullable=true)
  125.      */
  126.     private $swift;
  127.     /**
  128.      * @ORM\Column(type="text", nullable=true)
  129.      */
  130.     protected $observaciones;
  131.     /**
  132.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  133.      */
  134.     protected $deletedAt;
  135.     /**
  136.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  137.      * @Gedmo\Timestampable(on="update")
  138.      */
  139.     protected $updatedAt;
  140.     /**
  141.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  142.      * @Gedmo\Timestampable(on="create")
  143.      */
  144.     protected $createdAt;
  145.     /**
  146.      * @ORM\Column(type="string", length=2, nullable=true, name="pais")
  147.      */
  148.     protected $pais;
  149.     /**
  150.      * @ORM\OneToOne(targetEntity="App\Entity\User", mappedBy="cliente")
  151.      */
  152.     protected $user;
  153.     /**
  154.      * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="cliente")
  155.      */
  156.     protected $valoraciones;
  157.     /**
  158.      * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="cliente")
  159.      */
  160.     private $actividades;
  161.     /**
  162.      * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="cliente")
  163.      */
  164.     protected $operaciones;
  165.     /*
  166.      * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="clientes")
  167.      * @ORM\JoinColumn(name="ciudad_id", referencedColumnName="id")
  168.      */
  169.     //protected $ciudad;
  170.     /**
  171.      * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="clientes")
  172.      * @ORM\JoinColumn(name="ccaa_id", referencedColumnName="id")
  173.      */
  174.     protected $ccaa;
  175.     /**
  176.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="clientes")
  177.      * @ORM\JoinColumn(name="provincia_id", referencedColumnName="id")
  178.      */
  179.     protected $provincia;
  180.     public function __construct()
  181.     {
  182.         $this->valoraciones = new ArrayCollection();
  183.         $this->operaciones = new ArrayCollection();
  184.         $this->actividades = new ArrayCollection();
  185.     }
  186.     public function __toString(): string
  187.     {
  188.         return $this->getRazonSocial() ? $this->getRazonSocial() : ($this->getUser() ? $this->getUser()?->getNombreCompleto() : '---');
  189.     }
  190.     public function getId(): ?string
  191.     {
  192.         return $this->id;
  193.     }
  194.     public function getRazonSocial(): ?string
  195.     {
  196.         return $this->razonSocial;
  197.     }
  198.     public function setRazonSocial(?string $razonSocial): self
  199.     {
  200.         $this->razonSocial $razonSocial;
  201.         return $this;
  202.     }
  203.     public function getAlias(): ?string
  204.     {
  205.         return $this->alias;
  206.     }
  207.     public function setAlias(?string $alias): self
  208.     {
  209.         $this->alias $alias;
  210.         return $this;
  211.     }
  212.     public function getIdentificacionTipo(): ?string
  213.     {
  214.         return $this->identificacionTipo;
  215.     }
  216.     public function setIdentificacionTipo(?string $identificacionTipo): self
  217.     {
  218.         $this->identificacionTipo $identificacionTipo;
  219.         return $this;
  220.     }
  221.     public function getIdentificacion(): ?string
  222.     {
  223.         return $this->identificacion;
  224.     }
  225.     public function setIdentificacion(?string $identificacion): self
  226.     {
  227.         $this->identificacion $identificacion;
  228.         return $this;
  229.     }
  230.     public function getIdentificacionFrontal(): ?string
  231.     {
  232.         return $this->identificacionFrontal;
  233.     }
  234.     public function setIdentificacionFrontal(?string $identificacionFrontal): self
  235.     {
  236.         $this->identificacionFrontal $identificacionFrontal;
  237.         return $this;
  238.     }
  239.     public function getIdentificacionFrontalFile(): ?File
  240.     {
  241.         return $this->identificacionFrontalFile;
  242.     }
  243.     public function setIdentificacionFrontalFile(?File $identificacionFrontalFile): self
  244.     {
  245.         $this->identificacionFrontalFile $identificacionFrontalFile;
  246.         if ($identificacionFrontalFile) {
  247.             // if 'updatedAt' is not defined in your entity, use another property
  248.             $this->setUpdatedAt(new \DateTime('now'));
  249.         }
  250.         return $this;
  251.     }
  252.     public function getIdentificacionTrasera(): ?string
  253.     {
  254.         return $this->identificacionTrasera;
  255.     }
  256.     public function setIdentificacionTrasera(?string $identificacionTrasera): self
  257.     {
  258.         $this->identificacionTrasera $identificacionTrasera;
  259.         return $this;
  260.     }
  261.     public function getIdentificacionTraseraFile(): ?File
  262.     {
  263.         return $this->identificacionTraseraFile;
  264.     }
  265.     public function setIdentificacionTraseraFile(?File $identificacionTraseraFile): self
  266.     {
  267.         $this->identificacionTraseraFile $identificacionTraseraFile;
  268.         if ($identificacionTraseraFile) {
  269.             // if 'updatedAt' is not defined in your entity, use another property
  270.             $this->setUpdatedAt(new \DateTime('now'));
  271.         }
  272.         return $this;
  273.     }
  274.     public function getIdioma(): ?string
  275.     {
  276.         return $this->idioma;
  277.     }
  278.     public function setIdioma(?string $idioma): self
  279.     {
  280.         $this->idioma $idioma;
  281.         return $this;
  282.     }
  283.     public function getEntidadBancaria(): ?string
  284.     {
  285.         return $this->entidadBancaria;
  286.     }
  287.     public function setEntidadBancaria(?string $entidadBancaria): self
  288.     {
  289.         $this->entidadBancaria $entidadBancaria;
  290.         return $this;
  291.     }
  292.     public function getIban(): ?string
  293.     {
  294.         return $this->iban;
  295.     }
  296.     public function setIban(?string $iban): self
  297.     {
  298.         $this->iban $iban;
  299.         return $this;
  300.     }
  301.     public function getObservaciones(): ?string
  302.     {
  303.         return $this->observaciones;
  304.     }
  305.     public function setObservaciones(?string $observaciones): self
  306.     {
  307.         $this->observaciones $observaciones;
  308.         return $this;
  309.     }
  310.     public function getDeletedAt(): ?\DateTimeInterface
  311.     {
  312.         return $this->deletedAt;
  313.     }
  314.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  315.     {
  316.         $this->deletedAt $deletedAt;
  317.         return $this;
  318.     }
  319.     public function getUpdatedAt(): ?\DateTimeInterface
  320.     {
  321.         return $this->updatedAt;
  322.     }
  323.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  324.     {
  325.         $this->updatedAt $updatedAt;
  326.         return $this;
  327.     }
  328.     public function getCreatedAt(): ?\DateTimeInterface
  329.     {
  330.         return $this->createdAt;
  331.     }
  332.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  333.     {
  334.         $this->createdAt $createdAt;
  335.         return $this;
  336.     }
  337.     public function getUser(): ?User
  338.     {
  339.         return $this->user;
  340.     }
  341.     public function setUser(?User $user): self
  342.     {
  343.         // unset the owning side of the relation if necessary
  344.         if ($user === null && $this->user !== null) {
  345.             $this->user->setCliente(null);
  346.         }
  347.         // set the owning side of the relation if necessary
  348.         if ($user !== null && $user->getCliente() !== $this) {
  349.             $user->setCliente($this);
  350.         }
  351.         $this->user $user;
  352.         return $this;
  353.     }
  354.     /**
  355.      * @return Collection|Valoracion[]
  356.      */
  357.     public function getValoraciones(): Collection
  358.     {
  359.         return $this->valoraciones;
  360.     }
  361.     public function addValoracione(Valoracion $valoracione): self
  362.     {
  363.         if (!$this->valoraciones->contains($valoracione)) {
  364.             $this->valoraciones[] = $valoracione;
  365.             $valoracione->setCliente($this);
  366.         }
  367.         return $this;
  368.     }
  369.     public function removeValoracione(Valoracion $valoracione): self
  370.     {
  371.         if ($this->valoraciones->removeElement($valoracione)) {
  372.             // set the owning side to null (unless already changed)
  373.             if ($valoracione->getCliente() === $this) {
  374.                 $valoracione->setCliente(null);
  375.             }
  376.         }
  377.         return $this;
  378.     }
  379.     /**
  380.      * @return Collection|Operacion[]
  381.      */
  382.     public function getOperaciones(): Collection
  383.     {
  384.         return $this->operaciones;
  385.     }
  386.     public function addOperacione(Operacion $operacione): self
  387.     {
  388.         if (!$this->operaciones->contains($operacione)) {
  389.             $this->operaciones[] = $operacione;
  390.             $operacione->setCliente($this);
  391.         }
  392.         return $this;
  393.     }
  394.     public function removeOperacione(Operacion $operacione): self
  395.     {
  396.         if ($this->operaciones->removeElement($operacione)) {
  397.             // set the owning side to null (unless already changed)
  398.             if ($operacione->getCliente() === $this) {
  399.                 $operacione->setCliente(null);
  400.             }
  401.         }
  402.         return $this;
  403.     }
  404.     public function getTelefono(): ?string
  405.     {
  406.         return $this->telefono;
  407.     }
  408.     public function setTelefono(?string $telefono): self
  409.     {
  410.         $this->telefono $telefono;
  411.         return $this;
  412.     }
  413.     public function getEmail(): ?string
  414.     {
  415.         return $this->email;
  416.     }
  417.     public function setEmail(?string $email): self
  418.     {
  419.         $this->email $email;
  420.         return $this;
  421.     }
  422.     public function getDireccion(): ?string
  423.     {
  424.         return $this->direccion;
  425.     }
  426.     public function setDireccion(?string $direccion): self
  427.     {
  428.         $this->direccion $direccion;
  429.         return $this;
  430.     }
  431.     public function getCp(): ?string
  432.     {
  433.         return $this->cp;
  434.     }
  435.     public function setCp(?string $cp): self
  436.     {
  437.         $this->cp $cp;
  438.         return $this;
  439.     }
  440.     public function getCiudad(): ?string
  441.     {
  442.         return $this->ciudad;
  443.     }
  444.     public function setCiudad(?string $ciudad): self
  445.     {
  446.         $this->ciudad $ciudad;
  447.         return $this;
  448.     }
  449.     public function getCcaa(): ?CCAA
  450.     {
  451.         return $this->ccaa;
  452.     }
  453.     public function setCcaa(?CCAA $ccaa): self
  454.     {
  455.         $this->ccaa $ccaa;
  456.         return $this;
  457.     }
  458.     public function getPais(): ?string
  459.     {
  460.         return $this->pais;
  461.     }
  462.     public function setPais(?string $pais): self
  463.     {
  464.         $this->pais $pais;
  465.         return $this;
  466.     }
  467.     public function getProvincia(): ?Provincia
  468.     {
  469.         return $this->provincia;
  470.     }
  471.     public function setProvincia(?Provincia $provincia): self
  472.     {
  473.         $this->provincia $provincia;
  474.         return $this;
  475.     }
  476.     /**
  477.      * @return Collection<int, ActividadAbstract>
  478.      */
  479.     public function getActividades(): Collection
  480.     {
  481.         return $this->actividades;
  482.     }
  483.     public function addActividade(ActividadAbstract $actividade): static
  484.     {
  485.         if (!$this->actividades->contains($actividade)) {
  486.             $this->actividades->add($actividade);
  487.             $actividade->setCliente($this);
  488.         }
  489.         return $this;
  490.     }
  491.     public function removeActividade(ActividadAbstract $actividade): static
  492.     {
  493.         if ($this->actividades->removeElement($actividade)) {
  494.             // set the owning side to null (unless already changed)
  495.             if ($actividade->getCliente() === $this) {
  496.                 $actividade->setCliente(null);
  497.             }
  498.         }
  499.         return $this;
  500.     }
  501.     public function getRegion(): ?string
  502.     {
  503.         return $this->region;
  504.     }
  505.     public function setRegion(?string $region): static
  506.     {
  507.         $this->region $region;
  508.         return $this;
  509.     }
  510.     public function getExportPais(): ?string
  511.     {
  512.         return $this->getPais() ? Countries::getName($this->getPais()) : null;
  513.     }
  514.     public function getSwift(): ?string
  515.     {
  516.         return $this->swift;
  517.     }
  518.     public function setSwift(?string $swift): static
  519.     {
  520.         $this->swift $swift;
  521.         return $this;
  522.     }
  523. }