src/Application/Sonata/UserBundle/Entity/User.php line 40

Open in your IDE?
  1. <?php
  2. namespace App\Application\Sonata\UserBundle\Entity;
  3. use App\Entity\BoletimMedicao;
  4. use App\Entity\Cliente;
  5. use App\Entity\Colaborador;
  6. use App\Entity\CompanyDataRestrictable;
  7. use App\Entity\ContratoCliente;
  8. use App\Entity\DiarioObra;
  9. use App\Entity\Empresa;
  10. use App\Entity\FluxoCaixa;
  11. use App\Entity\Fornecedor;
  12. use App\Entity\OrdemDeServico;
  13. use App\Entity\PerfilUser;
  14. use App\Entity\PropostaComercial;
  15. use App\Entity\RelatorioTecnico;
  16. use App\Entity\Servico;
  17. use Doctrine\Common\Collections\ArrayCollection;
  18. use Doctrine\Common\Collections\Collection;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Sonata\UserBundle\Entity\BaseUser as BaseUser;
  21. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  22. use Symfony\Component\HttpFoundation\File\UploadedFile;
  23. use Symfony\Component\Serializer\Annotation\Groups;
  24. use Symfony\Component\Validator\Constraints as Assert;
  25. /**
  26.  * This file has been generated by the SonataEasyExtendsBundle.
  27.  *
  28.  * @link https://sonata-project.org/easy-extends
  29.  *
  30.  * References:
  31.  * @link http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
  32.  *
  33.  * @UniqueEntity("username", message="Já existe alguém cadastrado com este nome de usuário.")
  34.  * @UniqueEntity("email")
  35.  * @UniqueEntity("cpfCnpj")
  36.  */
  37. class User extends BaseUser implements CompanyDataRestrictable
  38. {
  39.     /**
  40.      * @var int $id
  41.      * @Groups({"read"})
  42.      */
  43.     protected $id;
  44.     /**
  45.      * @var string
  46.      * @Groups({"read", "write"})
  47.      * @Assert\NotBlank(groups={"Default","Registration","Profile"})
  48.      */
  49.     protected $username;
  50.     /**
  51.      * @var string
  52.      * @Assert\NotBlank(groups={"Registration"})
  53.      */
  54.     protected $plainPassword;
  55.     /**
  56.      * @var string
  57.      * @Groups({"read", "write"})
  58.      * @Assert\NotBlank(groups={"Default","Registration","Profile"})
  59.      * @Assert\Email(checkHost=true, groups={"Default","Registration","Profile"})
  60.      */
  61.     protected $email;
  62.     /**
  63.      * @var string
  64.      * @Groups({"read", "write"})
  65.      * Assert\NotBlank(groups={"Default","Registration","Profile"})
  66.      * AppAssert\CpfCnpj(mask=false)
  67.      */
  68.     protected $cpfCnpj;
  69.     /**
  70.      * @var string
  71.      * @Groups({"read", "write"})
  72.      * @Assert\NotBlank(groups={"Default","Registration","Profile"})
  73.      */
  74.     protected $firstname;
  75.     /**
  76.      * @var string
  77.      * @Groups({"read", "write"})
  78.      */
  79.     protected $lastname;
  80.     /**
  81.      * @var string
  82.      * @Groups({"read"})
  83.      */
  84.     protected $nome;
  85.     /**
  86.      * @var string Path of file
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      */
  89.     protected $avatarOriginal;
  90.     /**
  91.      * @var string
  92.      *
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      * @Groups({"read", "write"})
  95.      */
  96.     private $avatar;
  97.     /**
  98.      * @var string
  99.      * @Groups({"read", "write"})
  100.      * Assert\NotBlank(groups={"Default","Registration","Profile"})
  101.      */
  102.     protected $uf 'GO';
  103.     /**
  104.      * @var string
  105.      * @Groups({"read", "write"})
  106.      */
  107.     protected $gender;
  108.     /**
  109.      * @var string
  110.      * @Groups({"read", "write"})
  111.      */
  112.     protected $phone;
  113.     /**
  114.      * @var \DateTime
  115.      * @Groups({"read", "write"})
  116.      */
  117.     protected $dateOfBirth;
  118.     /**
  119.      * @var \DateTime
  120.      * @Groups({"read", "write"})
  121.      */
  122.     protected $createdAt;
  123.     /**
  124.      * @var \DateTime
  125.      * @Groups({"read", "write"})
  126.      */
  127.     protected $updatedAt;
  128.     /**
  129.      * @var UploadedFile
  130.      * @Groups({"none"})
  131.      */
  132.     private $avatarFile;
  133.     private $status true;
  134.     /**
  135.      * @ORM\ManyToOne(targetEntity="App\Entity\Empresa", inversedBy="usuarios")
  136.      */
  137.     private $franquia;
  138.     /**
  139.      * @ORM\OneToMany(targetEntity="App\Entity\Empresa", mappedBy="usuarioAdmin")
  140.      */
  141.     private $empresas;
  142.     /**
  143.      * @ORM\OneToMany(targetEntity="App\Entity\Servico", mappedBy="lastUpdatedUserAt")
  144.      */
  145.     private $servicosAlterados;
  146.     /**
  147.      * @ORM\OneToMany(targetEntity="App\Entity\PropostaComercial", mappedBy="cadastradoPor")
  148.      */
  149.     private $propostasComerciais;
  150.     /**
  151.      * @ORM\OneToMany(targetEntity="App\Entity\OrdemSeServico", mappedBy="cadastradoPor")
  152.      */
  153.     private $ordensDeServico;
  154.     /**
  155.      * @ORM\OneToMany(targetEntity="App\Entity\Fornecedor", mappedBy="cadastradoPor")
  156.      */
  157.     private $fornecedores;
  158.     /**
  159.      * @ORM\OneToMany(targetEntity="App\Entity\Colaborador", mappedBy="cadastradoPor")
  160.      */
  161.     private $colaboradores;
  162.     /**
  163.      * @ORM\OneToMany(targetEntity="App\Entity\ContratoCliente", mappedBy="cadastradoPor")
  164.      */
  165.     private $contratos;
  166.     /**
  167.      * @ORM\OneToMany(targetEntity="App\Entity\DiarioObra", mappedBy="cadastradoPor")
  168.      */
  169.     private $diariosDeObra;
  170.     /**
  171.      * @ORM\OneToMany(targetEntity="App\Entity\BoletimMedicao", mappedBy="cadastradoPor")
  172.      */
  173.     private $boletins;
  174.     /**
  175.      * @ORM\OneToMany(targetEntity="App\Entity\RelatorioTecnico", mappedBy="cadastradoPor")
  176.      */
  177.     private $relatoriosTecnicos;
  178.     /**
  179.      * @ORM\OneToMany(targetEntity="App\Entity\FluxoCaixa", mappedBy="cadastradoPor")
  180.      */
  181.     private $fluxosCaixa;
  182.     /**
  183.      * @ORM\ManyToOne(targetEntity="App\Entity\Empresa", inversedBy="cadastradoPor")
  184.      */
  185.     private $clientes;
  186.     /**
  187.      * @ORM\ManyToOne(targetEntity="App\Entity\Empresa", inversedBy="cadastradoPor")
  188.      */
  189.     private $contasReceber;
  190.     /**
  191.      * @ORM\ManyToOne(targetEntity="App\Entity\Empresa", inversedBy="usuarioAdmin")
  192.      */
  193.     private $empresasUsuarios;
  194.     
  195.     /**
  196.      * @ORM\ManyToOne(targetEntity="App\Entity\ArquivoColaborador", inversedBy="cadastradoPor")
  197.      */
  198.     private $arquivosColaborador;
  199.     
  200.     /**
  201.      * @ORM\ManyToOne(targetEntity="App\Entity\ArquivoOs", inversedBy="cadastradoPor")
  202.      */
  203.     private $arquivosOs;
  204.     
  205.     /**
  206.      * @ORM\ManyToOne(targetEntity="App\Entity\ArquivoEmpresa", inversedBy="cadastradoPor")
  207.      */
  208.     private $arquivosEmpresa;
  209.     public function __construct()
  210.     {
  211.         parent::__construct();
  212.         $this->empresas = new ArrayCollection();
  213.         $this->servicosAlterados = new ArrayCollection();
  214.         $this->propostasComerciais = new ArrayCollection();
  215.         $this->ordensDeServico = new ArrayCollection();
  216.         $this->fornecedores = new ArrayCollection();
  217.         $this->colaboradores = new ArrayCollection();
  218.         $this->contratos = new ArrayCollection();
  219.         $this->diariosDeObra = new ArrayCollection();
  220.         $this->boletins = new ArrayCollection();
  221.         $this->relatoriosTecnicos = new ArrayCollection();
  222.         $this->fluxosCaixa = new ArrayCollection();
  223.         $this->clientes = new ArrayCollection();
  224.         $this->contasReceber = new ArrayCollection();
  225.         $this->empresasUsuarios = new ArrayCollection();
  226.     }
  227.     /**
  228.      * Get id.
  229.      *
  230.      * @return int $id
  231.      */
  232.     public function getId()
  233.     {
  234.         return $this->id;
  235.     }
  236.     /**
  237.      * @return string
  238.      */
  239.     public function getCpfCnpj(): ?string
  240.     {
  241.         return $this->cpfCnpj;
  242.     }
  243.     /**
  244.      * @param string $cpfCnpj
  245.      * @return User
  246.      */
  247.     public function setCpfCnpj($cpfCnpj): User
  248.     {
  249.         $this->cpfCnpj $cpfCnpj;
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return string
  254.      */
  255.     public function getUf(): ?string
  256.     {
  257.         return $this->uf;
  258.     }
  259.     public function setUf(?string $uf): self
  260.     {
  261.         $this->uf $uf;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return string
  266.      */
  267.     public function getAvatarOriginal(): ?string
  268.     {
  269.         return $this->avatarOriginal;
  270.     }
  271.     /**
  272.      * @param string $avatarOriginal
  273.      * @return User
  274.      */
  275.     public function setAvatarOriginal(?string $avatarOriginal): self
  276.     {
  277.         $this->avatarOriginal $avatarOriginal;
  278.         return $this;
  279.     }
  280.     /**
  281.      * @return string
  282.      */
  283.     public function getAvatar(): ?string
  284.     {
  285.         return $this->avatar;
  286.     }
  287.     /**
  288.      * @param string $avatar
  289.      * @return User
  290.      */
  291.     public function setAvatar(?string $avatar): self
  292.     {
  293.         $this->avatar $avatar;
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return string
  298.      */
  299.     public function getNome(): string
  300.     {
  301.         return trim($this->firstname " " $this->lastname);
  302.     }
  303.     /**
  304.      * @return UploadedFile
  305.      */
  306.     public function getAvatarFile(): ?UploadedFile
  307.     {
  308.         return $this->avatarFile;
  309.     }
  310.     /**
  311.      * @param UploadedFile $avatarFile
  312.      * @return User
  313.      */
  314.     public function setAvatarFile(UploadedFile $avatarFile null): self
  315.     {
  316.         $this->avatarFile $avatarFile;
  317.         return $this;
  318.     }
  319.     public function getFranquia(): ?Empresa
  320.     {
  321.         return $this->franquia;
  322.     }
  323.     public function setFranquia(?Empresa $franquia): self
  324.     {
  325.         $this->franquia $franquia;
  326.         return $this;
  327.     }
  328.     /**
  329.      * @return Collection|Empresa[]
  330.      */
  331.     public function getEmpresas(): Collection
  332.     {
  333.         return $this->empresas;
  334.     }
  335.     public function addEmpresa(Empresa $empresa): self
  336.     {
  337.         if (!$this->empresas->contains($empresa)) {
  338.             $this->empresas[] = $empresa;
  339.             $empresa->setUsuarioAdmin($this);
  340.         }
  341.         return $this;
  342.     }
  343.     public function removeEmpresa(Empresa $empresa): self
  344.     {
  345.         if ($this->empresas->contains($empresa)) {
  346.             $this->empresas->removeElement($empresa);
  347.             // set the owning side to null (unless already changed)
  348.             if ($empresa->getUsuarioAdmin() === $this) {
  349.                 $empresa->setUsuarioAdmin(null);
  350.             }
  351.         }
  352.         return $this;
  353.     }
  354.     /**
  355.      * @return Collection|Servico[]
  356.      */
  357.     public function getServicosAlterados(): Collection
  358.     {
  359.         return $this->servicosAlterados;
  360.     }
  361.     public function addServicosAlterado(Servico $servicosAlterado): self
  362.     {
  363.         if (!$this->servicosAlterados->contains($servicosAlterado)) {
  364.             $this->servicosAlterados[] = $servicosAlterado;
  365.             $servicosAlterado->setLastUpdatedUserAt($this);
  366.         }
  367.         return $this;
  368.     }
  369.     public function removeServicosAlterado(Servico $servicosAlterado): self
  370.     {
  371.         if ($this->servicosAlterados->contains($servicosAlterado)) {
  372.             $this->servicosAlterados->removeElement($servicosAlterado);
  373.             // set the owning side to null (unless already changed)
  374.             if ($servicosAlterado->getLastUpdatedUserAt() === $this) {
  375.                 $servicosAlterado->setLastUpdatedUserAt(null);
  376.             }
  377.         }
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return Collection|PropostaComercial[]
  382.      */
  383.     public function getPropostasComerciais(): Collection
  384.     {
  385.         return $this->propostasComerciais;
  386.     }
  387.     public function addPropostasComerciai(PropostaComercial $propostasComerciai): self
  388.     {
  389.         if (!$this->propostasComerciais->contains($propostasComerciai)) {
  390.             $this->propostasComerciais[] = $propostasComerciai;
  391.             $propostasComerciai->setCadastradoPor($this);
  392.         }
  393.         return $this;
  394.     }
  395.     public function removePropostasComerciai(PropostaComercial $propostasComerciai): self
  396.     {
  397.         if ($this->propostasComerciais->contains($propostasComerciai)) {
  398.             $this->propostasComerciais->removeElement($propostasComerciai);
  399.             // set the owning side to null (unless already changed)
  400.             if ($propostasComerciai->getCadastradoPor() === $this) {
  401.                 $propostasComerciai->setCadastradoPor(null);
  402.             }
  403.         }
  404.         return $this;
  405.     }
  406.     /**
  407.      * @return Collection|OrdemDeServico[]
  408.      */
  409.     public function getOrdensDeServico(): Collection
  410.     {
  411.         return $this->propostasComerciais;
  412.     }
  413.     public function addOrdemDeServico(OrdemDeServico $ordemDeServico): self
  414.     {
  415.         if (!$this->ordensDeServico->contains($ordemDeServico)) {
  416.             $this->ordensDeServico[] = $ordemDeServico;
  417.             $ordemDeServico->setCadastradoPor($this);
  418.         }
  419.         return $this;
  420.     }
  421.     public function removeOrdemDeServico(OrdemDeServico $ordemDeServico): self
  422.     {
  423.         if ($this->ordensDeServico->contains($ordemDeServico)) {
  424.             $this->ordensDeServico->removeElement($ordemDeServico);
  425.             // set the owning side to null (unless already changed)
  426.             if ($ordemDeServico->getCadastradoPor() === $this) {
  427.                 $ordemDeServico->setCadastradoPor(null);
  428.             }
  429.         }
  430.         return $this;
  431.     }
  432.     /**
  433.      * @return Collection|Fornecedor[]
  434.      */
  435.     public function getFornecedores(): Collection
  436.     {
  437.         return $this->fornecedores;
  438.     }
  439.     public function addFornecedor(OrdemDeServico $fornecedor): self
  440.     {
  441.         if (!$this->fornecedores->contains($fornecedor)) {
  442.             $this->fornecedores[] = $fornecedor;
  443.             $fornecedor->setCadastradoPor($this);
  444.         }
  445.         return $this;
  446.     }
  447.     public function removeFornecedor(OrdemDeServico $fornecedor): self
  448.     {
  449.         if ($this->fornecedores->contains($fornecedor)) {
  450.             $this->fornecedores->removeElement($fornecedor);
  451.             // set the owning side to null (unless already changed)
  452.             if ($fornecedor->getCadastradoPor() === $this) {
  453.                 $fornecedor->setCadastradoPor(null);
  454.             }
  455.         }
  456.         return $this;
  457.     }
  458.     /**
  459.      * @return Collection|Colaborador[]
  460.      */
  461.     public function getColaboradores(): Collection
  462.     {
  463.         return $this->colaboradores;
  464.     }
  465.     public function addColaborador(Colaborador $colaborador): self
  466.     {
  467.         if (!$this->colaboradores->contains($colaborador)) {
  468.             $this->colaboradores[] = $colaborador;
  469.             $colaborador->setCadastradoPor($this);
  470.         }
  471.         return $this;
  472.     }
  473.     public function removeColaborador(Colaborador $colaborador): self
  474.     {
  475.         if ($this->colaboradores->contains($colaborador)) {
  476.             $this->colaboradores->removeElement($colaborador);
  477.             // set the owning side to null (unless already changed)
  478.             if ($colaborador->getCadastradoPor() === $this) {
  479.                 $colaborador->setCadastradoPor(null);
  480.             }
  481.         }
  482.         return $this;
  483.     }
  484.     /**
  485.      * @return Collection|ContratoCliente[]
  486.      */
  487.     public function getContratos(): Collection
  488.     {
  489.         return $this->contratos;
  490.     }
  491.     public function addContrato(ContratoCliente $contrato): self
  492.     {
  493.         if (!$this->contratos->contains($contrato)) {
  494.             $this->contratos[] = $contrato;
  495.             $contrato->setCadastradoPor($this);
  496.         }
  497.         return $this;
  498.     }
  499.     public function removeContrato(ContratoCliente $contrato): self
  500.     {
  501.         if ($this->contratos->contains($contrato)) {
  502.             $this->contratos->removeElement($contrato);
  503.             // set the owning side to null (unless already changed)
  504.             if ($contrato->getCadastradoPor() === $this) {
  505.                 $contrato->setCadastradoPor(null);
  506.             }
  507.         }
  508.         return $this;
  509.     }
  510.     /**
  511.      * @return Collection|DiarioObra[]
  512.      */
  513.     public function getDiariosObra(): Collection
  514.     {
  515.         return $this->diariosDeObra;
  516.     }
  517.     public function addDiariosObra(DiarioObra $diarioObra): self
  518.     {
  519.         if (!$this->diariosDeObra->contains($diarioObra)) {
  520.             $this->diariosDeObra[] = $diarioObra;
  521.             $diarioObra->setCadastradoPor($this);
  522.         }
  523.         return $this;
  524.     }
  525.     public function removeDiarioObra(DiarioObra $diarioObra): self
  526.     {
  527.         if ($this->diariosDeObra->contains($diarioObra)) {
  528.             $this->diariosDeObra->removeElement($diarioObra);
  529.             // set the owning side to null (unless already changed)
  530.             if ($diarioObra->getCadastradoPor() === $this) {
  531.                 $diarioObra->setCadastradoPor(null);
  532.             }
  533.         }
  534.         return $this;
  535.     }
  536.     /**
  537.      * @return Collection|BoletimMedicao[]
  538.      */
  539.     public function getBoletins(): Collection
  540.     {
  541.         return $this->boletins;
  542.     }
  543.     public function addBoletim(BoletimMedicao $boletimMedicao): self
  544.     {
  545.         if (!$this->boletins->contains($boletimMedicao)) {
  546.             $this->boletins[] = $boletimMedicao;
  547.             $boletimMedicao->setCadastradoPor($this);
  548.         }
  549.         return $this;
  550.     }
  551.     public function removeBoletim(BoletimMedicao $boletimMedicao): self
  552.     {
  553.         if ($this->boletins->contains($boletimMedicao)) {
  554.             $this->boletins->removeElement($boletimMedicao);
  555.             // set the owning side to null (unless already changed)
  556.             if ($boletimMedicao->getCadastradoPor() === $this) {
  557.                 $boletimMedicao->setCadastradoPor(null);
  558.             }
  559.         }
  560.         return $this;
  561.     }
  562.     /**
  563.      * @return Collection|RelatorioTecnico[]
  564.      */
  565.     public function getRelatoriosTecnicos(): Collection
  566.     {
  567.         return $this->relatoriosTecnicos;
  568.     }
  569.     public function addRelatorioTecnico(RelatorioTecnico $relatorioTecnico): self
  570.     {
  571.         if (!$this->relatoriosTecnicos->contains($relatorioTecnico)) {
  572.             $this->relatoriosTecnicos[] = $relatorioTecnico;
  573.             $relatorioTecnico->setCadastradoPor($this);
  574.         }
  575.         return $this;
  576.     }
  577.     public function removeRelatorioTecnico(RelatorioTecnico $relatorioTecnico): self
  578.     {
  579.         if ($this->relatoriosTecnicos->contains($relatorioTecnico)) {
  580.             $this->relatoriosTecnicos->removeElement($relatorioTecnico);
  581.             // set the owning side to null (unless already changed)
  582.             if ($relatorioTecnico->getCadastradoPor() === $this) {
  583.                 $relatorioTecnico->setCadastradoPor(null);
  584.             }
  585.         }
  586.         return $this;
  587.     }
  588.     /**
  589.      * @return Collection|FluxoCaixa[]
  590.      */
  591.     public function getFluxosCaixa(): Collection
  592.     {
  593.         return $this->fluxosCaixa;
  594.     }
  595.     public function addFluxosCaixa(FluxoCaixa $fluxoCaixa): self
  596.     {
  597.         if (!$this->fluxosCaixa->contains($fluxoCaixa)) {
  598.             $this->fluxosCaixa[] = $fluxoCaixa;
  599.             $fluxoCaixa->setCadastradoPor($this);
  600.         }
  601.         return $this;
  602.     }
  603.     public function removeFluxosCaixa(FluxoCaixa $fluxoCaixa): self
  604.     {
  605.         if ($this->fluxosCaixa->contains($fluxoCaixa)) {
  606.             $this->fluxosCaixa->removeElement($fluxoCaixa);
  607.             // set the owning side to null (unless already changed)
  608.             if ($fluxoCaixa->getCadastradoPor() === $this) {
  609.                 $fluxoCaixa->setCadastradoPor(null);
  610.             }
  611.         }
  612.         return $this;
  613.     }
  614.     /**
  615.      * @return Collection|Cliente[]
  616.      */
  617.     public function getClientes(): Collection
  618.     {
  619.         return $this->clientes;
  620.     }
  621.     public function addCliente(Cliente $cliente): self
  622.     {
  623.         if (!$this->clientes->contains($cliente)) {
  624.             $this->clientes[] = $cliente;
  625.             $cliente->setCadastradoPor($this);
  626.         }
  627.         return $this;
  628.     }
  629.     public function removeCliente(Cliente $cliente): self
  630.     {
  631.         if ($this->clientes->contains($cliente)) {
  632.             $this->clientes->removeElement($cliente);
  633.             // set the owning side to null (unless already changed)
  634.             if ($cliente->getCadastradoPor() === $this) {
  635.                 $cliente->setCadastradoPor(null);
  636.             }
  637.         }
  638.         return $this;
  639.     }
  640.     /**
  641.      * @return Collection|Empresa[]
  642.      */
  643.     public function getEmpresasUsuarios(): Collection
  644.     {
  645.         return $this->empresasUsuarios;
  646.     }
  647.     public function addEmpresaUsuario(Empresa $empresa): self
  648.     {
  649.         if (!$this->empresasUsuarios->contains($empresa)) {
  650.             $this->empresasUsuarios[] = $empresa;
  651.             $empresa->setUsuarioAdmin($this);
  652.         }
  653.         return $this;
  654.     }
  655.     public function removeEmpresaUsuario(Empresa $empresa): self
  656.     {
  657.         if ($this->empresasUsuarios->contains($empresa)) {
  658.             $this->empresasUsuarios->removeElement($empresa);
  659.             // set the owning side to null (unless already changed)
  660.             if ($empresa->getUsuarioAdmin() === $this) {
  661.                 $empresa->setUsuarioAdmin(null);
  662.             }
  663.         }
  664.         return $this;
  665.     }
  666. }