src/Application/Internit/ClienteBundle/Entity/Cliente.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Application\Internit\ClienteBundle\Entity;
  3. use App\Application\Internit\ClienteBundle\Repository\ClienteRepository;
  4. use App\Application\Internit\UnidadeClienteBundle\Entity\UnidadeCliente;
  5. use App\Application\Internit\DownloadBundle\Entity\Download;
  6. use App\Application\Internit\ComunicadoBundle\Entity\Comunicado;
  7. use App\Application\Project\ContentBundle\Entity\BaseUser;
  8. use App\Application\Project\SecurityUserBundle\Entity\Group;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use App\Entity\SonataMediaGallery;
  14. use App\Entity\SonataMediaMedia;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use DateTime;
  17. /** Info:  */
  18. #[ORM\Table(name'cliente')]
  19. #[ORM\Entity(repositoryClassClienteRepository::class)]
  20. #[UniqueEntity('id')]
  21. #[UniqueEntity('cpf')]
  22. class Cliente extends BaseUser
  23. {
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column(name'id'type'integer'uniquetruenullablefalse)]
  27.     private ?int $id null;
  28.     #[ORM\Column(name'import_id'type'integer'uniquefalsenullabletrue)]
  29.     private ?int $importId;
  30.     #[ORM\Column(name'import'type'boolean'uniquefalsenullabletrue)]
  31.     private ?bool $import;
  32.     #[ORM\Column(name'ativo'type'boolean'uniquefalsenullabletrue)]
  33.     private ?bool $ativo null;
  34.     #[ORM\ManyToMany(targetEntityGroup::class)]
  35.     #[ORM\JoinTable(name"security_cliente_group")]
  36.     #[ORM\JoinColumn(name"cliente_id"referencedColumnName"id")]
  37.     #[ORM\InverseJoinColumn(name"group_id"referencedColumnName"id")]
  38.     private $groups;
  39.     #[Assert\NotNull]
  40.     #[Assert\NotBlank]
  41.     #[ORM\Column(name'nomeCompleto'type'string'uniquefalsenullablefalse)]
  42.     private string $nomeCompleto;
  43.     #[ORM\Column(name'razaoSocial'type'string'uniquefalsenullabletrue)]
  44.     private ?string $razaoSocial;
  45.     #[ORM\Column(name'nomeFantasia'type'string'uniquefalsenullabletrue)]
  46.     private ?string $nomeFantasia;
  47.     #[ORM\Column(name'cpf'type'string'length14uniquefalsenullabletrue)]
  48.     private  ?string $cpf;
  49.     #[ORM\Column(name'cnpj'type'string'length24uniquefalsenullabletrue)]
  50.     private  ?string $cnpj;
  51.     #[ORM\Column(name'telefone'type'string'uniquefalsenullabletrue)]
  52.     private ?string $telefone null;
  53.     #[ORM\Column(name'celular'type'string'uniquefalsenullabletrue)]
  54.     private ?string $celular null;
  55.     #[ORM\OneToMany(mappedBy'cliente'targetEntityUnidadeCliente::class)]
  56.     private Collection $unidades;
  57.     #[ORM\ManyToMany(targetEntityDownload::class, mappedBy'clientes')]
  58.     private Collection $downloads;
  59.     #[ORM\ManyToMany(targetEntityComunicado::class, mappedBy'clientes')]
  60.     private Collection $comunicados;
  61.     #[ORM\OneToMany(mappedBy'associado'targetEntityCliente::class)]
  62.     private Collection $dependentes;
  63.     #[ORM\ManyToOne(targetEntityCliente::class, inversedBy'dependentes')]
  64.     #[ORM\JoinColumn(name'associado_id'referencedColumnName'id')]
  65.     private Cliente|null $associado null;
  66.     #[ORM\Column(name'hash_nova_senha'type"string"nullabletrue)]
  67.     protected ?string $hashNovaSenha '';
  68.     #[ORM\Column(name'data_hash_nova_senha'type"datetime"nullabletrue)]
  69.     protected ?DateTime $dataHashNovaSenha;
  70.     public function __construct()
  71.     {
  72.         $this->unidades = new ArrayCollection();
  73.         $this->downloads = new ArrayCollection();
  74.         $this->comunicados = new ArrayCollection();
  75.         $this->groups = new ArrayCollection();
  76.         $this->dependentes = new ArrayCollection();
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     /**
  83.      * @return int|null
  84.      */
  85.     public function getImportId(): ?int
  86.     {
  87.         return $this->importId;
  88.     }
  89.     /**
  90.      * @param int|null $importId
  91.      */
  92.     public function setImportId(?int $importId): void
  93.     {
  94.         $this->importId $importId;
  95.     }
  96.     public function isImport(): bool
  97.     {
  98.         return $this->import;
  99.     }
  100.     public function setImport(bool $import): void
  101.     {
  102.         $this->import $import;
  103.     }
  104.     public function getNomeCompleto(): string
  105.     {
  106.         return $this->nomeCompleto;
  107.     }
  108.     public function setNomeCompleto(string $nomeCompleto): void
  109.     {
  110.         $this->nomeCompleto $nomeCompleto;
  111.     }
  112.     public function getCpf(): ?string
  113.     {
  114.         return $this->cpf;
  115.     }
  116.     public function setCpf(?string $cpf): void
  117.     {
  118.         $this->cpf $cpf;
  119.     }
  120.     public function getCnpj(): ?string
  121.     {
  122.         return $this->cnpj;
  123.     }
  124.     public function setCnpj(?string $cnpj): void
  125.     {
  126.         $this->cnpj $cnpj;
  127.     }
  128.     public function getTelefone(): ?string
  129.     {
  130.         return $this->telefone;
  131.     }
  132.     public function setTelefone(?string $telefone): void
  133.     {
  134.         $this->telefone $telefone;
  135.     }
  136.     public function getCelular(): ?string
  137.     {
  138.         return $this->celular;
  139.     }
  140.     public function setCelular(?string $celular): void
  141.     {
  142.         $this->celular $celular;
  143.     }
  144.     public function getUnidades(): Collection
  145.     {
  146.         return $this->unidades;
  147.     }
  148.     public function setUnidades(Collection $unidades): void
  149.     {
  150.         $this->unidades $unidades;
  151.     }
  152.     public function getDownloads(): Collection
  153.     {
  154.         return $this->downloads;
  155.     }
  156.     public function setDownloads(Collection $downloads): void
  157.     {
  158.         $this->downloads $downloads;
  159.     }
  160.     public function getComunicados(): Collection
  161.     {
  162.         return $this->comunicados;
  163.     }
  164.     public function setComunicados(Collection $comunicados): void
  165.     {
  166.         $this->comunicados $comunicados;
  167.     }
  168.     public function getGroups()
  169.     {
  170.         return $this->groups;
  171.     }
  172.     public function setGroups($groups): void
  173.     {
  174.         $this->groups $groups;
  175.     }
  176.     public function getAtivo(): ?bool
  177.     {
  178.         return $this->ativo;
  179.     }
  180.     public function setAtivo(?bool $ativo): void
  181.     {
  182.         $this->ativo $ativo;
  183.     }
  184.     /**
  185.      * @return string|null
  186.      */
  187.     public function getRazaoSocial(): ?string
  188.     {
  189.         return $this->razaoSocial;
  190.     }
  191.     /**
  192.      * @param string|null $razaoSocial
  193.      */
  194.     public function setRazaoSocial(?string $razaoSocial): void
  195.     {
  196.         $this->razaoSocial $razaoSocial;
  197.     }
  198.     /**
  199.      * @return string|null
  200.      */
  201.     public function getNomeFantasia(): ?string
  202.     {
  203.         return $this->nomeFantasia;
  204.     }
  205.     /**
  206.      * @param string|null $nomeFantasia
  207.      */
  208.     public function setNomeFantasia(?string $nomeFantasia): void
  209.     {
  210.         $this->nomeFantasia $nomeFantasia;
  211.     }
  212.     public function getDependentes(): Collection
  213.     {
  214.         return $this->dependentes;
  215.     }
  216.     public function setDependentes(Collection $dependentes): void
  217.     {
  218.         $this->dependentes $dependentes;
  219.     }
  220.     public function getAssociado(): ?Cliente
  221.     {
  222.         return $this->associado;
  223.     }
  224.     public function setAssociado(?Cliente $associado): void
  225.     {
  226.         $this->associado $associado;
  227.     }
  228.     public function getRoles(): array
  229.     {
  230.         $apiRoles $this->getApiRoles();
  231.         $webRoles $this->getWebRoles();
  232.         foreach ($this->getGroups() as $group){
  233.             $apiRoles array_merge$apiRoles$group->getApiRoles() );
  234.             $webRoles array_merge$webRoles$group->getWebRoles() );
  235.         }
  236.         /** Merge de todas as roles do usuário */
  237.         $roles array_merge$this->roles$apiRoles$webRoles);
  238.         /** Limpa roles repedidas e retorna todas as roles do usuário */
  239.         return array_unique(array_values(array_filter($roles)));
  240.     }
  241.     public function getEmprendimentos($ativo true)
  242.     {
  243.         $empreendimentos = [];
  244.         /** @var  $unidadeCliente UnidadeCliente */
  245.         foreach ($this->getUnidades() as $unidadeCliente){
  246.             if( $ativo && (!$unidadeCliente->getAtivo()))
  247.                 continue;
  248.             if(!$unidadeCliente->getUnidade())
  249.                 continue;
  250.             if(!$unidadeCliente->getUnidade()->getBloco())
  251.                 continue;
  252.             if(!$unidadeCliente->getUnidade()->getBloco()->getEmpreendimento())
  253.                 continue;
  254.             $empreendimentos[] = $unidadeCliente->getUnidade()->getBloco()->getEmpreendimento();
  255.         }
  256.         return array_unique($empreendimentosSORT_REGULAR);
  257.     }
  258.     public function getAllBlocos($ativo true){
  259.         $blocos = [];
  260.         /** @var  $unidadeCliente UnidadeCliente */
  261.         foreach ($this->getUnidades() as $unidadeCliente){
  262.             if($ativo && (!$unidadeCliente->getAtivo()))
  263.                 continue;
  264.             if(!$unidadeCliente->getUnidade())
  265.                 continue;
  266.             if(!$unidadeCliente->getUnidade()->getBloco())
  267.                 continue;
  268.             $blocos[] = $unidadeCliente->getUnidade()->getBloco();
  269.         }
  270.         return array_unique($blocosSORT_REGULAR);
  271.     }
  272.     public function getAllUnidades($ativo true){
  273.         $unidades = [];
  274.         /** @var  $unidadeCliente UnidadeCliente */
  275.         foreach ($this->getUnidades() as $unidadeCliente){
  276.             if($ativo && (!$unidadeCliente->getAtivo()))
  277.                 continue;
  278.             if(!$unidadeCliente->getUnidade())
  279.                 continue;
  280.             $unidades[] = $unidadeCliente->getUnidade();
  281.         }
  282.         return array_unique($unidadesSORT_REGULAR);
  283.     }
  284.     public function getHashNovaSenha(): ?string
  285.     {
  286.         return $this->hashNovaSenha;
  287.     }
  288.     public function setHashNovaSenha(?string $hashNovaSenha): void
  289.     {
  290.         $this->hashNovaSenha $hashNovaSenha;
  291.     }
  292.     public function getDataHashNovaSenha(): ?DateTime
  293.     {
  294.         return $this->dataHashNovaSenha;
  295.     }
  296.     public function setDataHashNovaSenha(?DateTime $dataHashNovaSenha): void
  297.     {
  298.         $this->dataHashNovaSenha $dataHashNovaSenha;
  299.     }
  300. }