diff --git a/Controller/ImobiliariaController.php b/Controller/ImobiliariaController.php new file mode 100644 index 0000000..9203e35 --- /dev/null +++ b/Controller/ImobiliariaController.php @@ -0,0 +1,33 @@ +render('index.html.twig'); + + } + + /** + * @Route("dashboard", name="dashboard") + */ + public function dashboard() + { + + return $this->render('imobiliaria.html.twig'); + + } +} \ No newline at end of file diff --git a/Controller/ImovelController.php b/Controller/ImovelController.php new file mode 100644 index 0000000..a674df8 --- /dev/null +++ b/Controller/ImovelController.php @@ -0,0 +1,86 @@ +createForm(ImovelType::class, $imovel); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $imovel = $form->getData(); + $em = $this->getDoctrine()->getManager(); + $em->persist($imovel); + $em->flush(); + + return $this->redirectToRoute('index'); + } + + return $this->render('imovel_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + + } + + /** + * @Route("/imovel/listar", name="listar_imoveis") + */ + public function listarImoveis() + { + $em = $this->getDoctrine()->getManager(); + $imoveis = $em->getRepository(Imovel::class)->findAll(); + + return $this->render('listar_imoveis.html.twig', [ + 'imoveis' => $imoveis + ]); + } + + /** + * @Route("/imovel/portifolios", name="listar_portifolios") + */ + public function imoveisPortifolios() + { + $em = $this->getDoctrine()->getManager(); + $imoveis = $em->getRepository(Imovel::class)->findAll(); + + return $this->render('listar_portifolios.html.twig', [ + 'imoveis' => $imoveis + ]); + } + + /** + * @Route("/imovel/visualizar/{id}", name="imovel_visualizar") + */ + public function imovelVisualizar(Request $request) + { + $id = $request->get('id'); + $em = $this->getDoctrine()->getManager(); + $imovel = $em->getRepository(Imovel::class)->find($id); + + return $this->render('imovel_visualizar.html.twig', [ + 'imovel' => $imovel + ]); + } + + + +} \ No newline at end of file diff --git a/Controller/LoginController.php b/Controller/LoginController.php new file mode 100644 index 0000000..9f5c57e --- /dev/null +++ b/Controller/LoginController.php @@ -0,0 +1,16 @@ +render(); + } + +} \ No newline at end of file diff --git a/Controller/SecurityController.php b/Controller/SecurityController.php new file mode 100644 index 0000000..b9c0725 --- /dev/null +++ b/Controller/SecurityController.php @@ -0,0 +1,33 @@ +getLastAuthenticationError(); + // last username entered by the user + $lastUsername = $authenticationUtils->getLastUsername(); + + return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); + } + + /** + * @Route("/logout", name="app_logout", methods={"GET"}) + */ + public function logout() + { + // controller can be blank: it will never be executed! + throw new \Exception('Don\'t forget to activate logout in security.yaml'); + } +} diff --git a/Controller/UsuarioController.php b/Controller/UsuarioController.php new file mode 100644 index 0000000..91cd16b --- /dev/null +++ b/Controller/UsuarioController.php @@ -0,0 +1,115 @@ +createForm(UsuarioType::class, $usuario); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $usuario = $form->getData(); + /*$em = $this->getDoctrine()->getManager(); + $em->persist($usuario); + $em->flush();*/ + $usuarioservice->salvar($usuario); + + return $this->redirectToRoute('index'); + } + + return $this->render('usuario_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + } + + /** + * @Route("/listar", name="listar_usuarios") + */ + public function listarUsuarios(Request $request) + { + $user = new Corretor(); + $user->setLogin('helio'); + $user->setRoles([true ? 'ROLE_ADMIN' : 'ROLE_USER']); + + $user->setPassword('ZkCCqGmNQXOeL1avsq2OWv2BSKLqHE33c2aolQ1nFxg'); + $em = $this->getDoctrine()->getManager(); + $em->persist($user); + $em->flush(); + + + + $em = $this->getDoctrine()->getManager(); + $usuarios = $em->getRepository(Usuario::class)->findAll(); + + return $this->render('listar_usuarios.html.twig', [ + 'usuarios' => $usuarios + ]); + } + + /** + * @Route("/editar/{id}", name="editar_usuario") + */ + public function editarUsuario(int $id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $usuario = $em->getRepository(Usuario::class)->find($id); + + if (!$usuario) { + throw new \Exception('Usuario não encontrado'); + } + + $form = $this->createForm(UsuarioType::class, $usuario); + + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $usuario = $form->getData(); + $em = $this->getDoctrine()->getManager(); + $em->merge($usuario); + $em->flush(); + + return $this->redirectToRoute('listar_usuarios'); + } + + return $this->render('usuario_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + } + + /** + * @Route("/deletar/{id}", name="deletar_usuario") + */ + public function deletarUsuario(int $id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $usuario = $em->getRepository(Usuario::class)->find($id); + $em->remove($usuario); + $em->flush(); + $this->addFlash('success', 'Usuario de id:'.$id.' deletado com sucesso!!!'); + + return $this->redirectToRoute('listar_usuarios'); + } +} diff --git a/Entity/Corretor.php b/Entity/Corretor.php new file mode 100644 index 0000000..c96d3c6 --- /dev/null +++ b/Entity/Corretor.php @@ -0,0 +1,113 @@ +id; + } + + public function getLogin(): ?string + { + return $this->login; + } + + public function setLogin(string $login): self + { + $this->login = $login; + + return $this; + } + + /** + * A visual identifier that represents this user. + * + * @see UserInterface + */ + public function getUsername(): string + { + return (string) $this->login; + } + + /** + * @see UserInterface + */ + public function getRoles(): array + { + $roles = $this->roles; + // guarantee every user at least has ROLE_USER + $roles[] = 'ROLE_USER'; + + return array_unique($roles); + } + + public function setRoles(array $roles): self + { + $this->roles = $roles; + + return $this; + } + + /** + * @see UserInterface + */ + public function getPassword(): string + { + return (string) $this->password; + } + + public function setPassword(string $password): self + { + $this->password = $password; + + return $this; + } + + /** + * @see UserInterface + */ + public function getSalt() + { + // not needed when using the "bcrypt" algorithm in security.yaml + } + + /** + * @see UserInterface + */ + public function eraseCredentials() + { + // If you store any temporary, sensitive data on the user, clear it here + // $this->plainPassword = null; + } +} diff --git a/Entity/Endereco.php b/Entity/Endereco.php new file mode 100644 index 0000000..388caf5 --- /dev/null +++ b/Entity/Endereco.php @@ -0,0 +1,307 @@ +id; + } + + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + + /** + * @return mixed + */ + public function getLogradouro() + { + return $this->logradouro; + } + + /** + * @param mixed $logradouro + */ + public function setLogradouro($logradouro): void + { + $this->logradouro = $logradouro; + } + + /** + * @return mixed + */ + public function getBairro() + { + return $this->bairro; + } + + /** + * @param mixed $bairro + */ + public function setBairro($bairro): void + { + $this->bairro = $bairro; + } + + /** + * @return mixed + */ + public function getNumero() + { + return $this->numero; + } + + /** + * @param mixed $numero + */ + public function setNumero($numero): void + { + $this->numero = $numero; + } + + /** + * @return mixed + */ + public function getCep() + { + return $this->cep; + } + + /** + * @param mixed $cep + */ + public function setCep($cep): void + { + $this->cep = $cep; + } + + /** + * @return mixed + */ + public function getComplemento() + { + return $this->complemento; + } + + /** + * @param mixed $complemento + */ + public function setComplemento($complemento): void + { + $this->complemento = $complemento; + } + + /** + * @return mixed + */ + public function getCidade() + { + return $this->cidade; + } + + /** + * @param mixed $cidade + */ + public function setCidade($cidade): void + { + $this->cidade = $cidade; + } + + /** + * @return mixed + */ + public function getUf() + { + return $this->uf; + } + + /** + * @param mixed $uf + */ + public function setUf($uf): void + { + $this->uf = $uf; + } + + /** + * @return mixed + */ + public function getTelefone() + { + return $this->telefone; + } + + /** + * @param mixed $telefone + */ + public function setTelefone($telefone): void + { + $this->telefone = $telefone; + } + + /** + * @return mixed + */ + public function getDddTelefone() + { + return $this->dddTelefone; + } + + /** + * @param mixed $dddTelefone + */ + public function setDddTelefone($dddTelefone): void + { + $this->dddTelefone = $dddTelefone; + } + + /** + * @return mixed + */ + public function getCelular() + { + return $this->celular; + } + + /** + * @param mixed $celular + */ + public function setCelular($celular): void + { + $this->celular = $celular; + } + + /** + * @return mixed + */ + public function getDddCelular() + { + return $this->dddCelular; + } + + /** + * @param mixed $dddCelular + */ + public function setDddCelular($dddCelular): void + { + $this->dddCelular = $dddCelular; + } + + /** + * @return mixed + */ + public function getCliente() + { + return $this->cliente; + } + + /** + * @param mixed $cliente + */ + public function setCliente($cliente): void + { + $this->cliente = $cliente; + } + + /** + * @return mixed + */ + public function getImovel() + { + return $this->imovel; + } + + /** + * @param mixed $imovel + */ + public function setImovel($imovel): void + { + $this->imovel = $imovel; + } +} diff --git a/Entity/Imovel.php b/Entity/Imovel.php new file mode 100644 index 0000000..890f5da --- /dev/null +++ b/Entity/Imovel.php @@ -0,0 +1,173 @@ +id; + } + + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + + /** + * @return mixed + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param mixed $status + */ + public function setStatus($status): void + { + $this->status = $status; + } + + /** + * @return mixed + */ + public function getCaracteristicas() + { + return $this->caracteristicas; + } + + /** + * @param mixed $caracteristicas + */ + public function setCaracteristicas($caracteristicas): void + { + $this->caracteristicas = $caracteristicas; + } + + /** + * @return mixed + */ + public function getObservacao() + { + return $this->observacao; + } + + /** + * @param mixed $observacao + */ + public function setObservacao($observacao): void + { + $this->observacao = $observacao; + } + + /** + * @return mixed + */ + public function getTipoImovel() + { + return $this->tipoImovel; + } + + /** + * @param mixed $tipoImovel + */ + public function setTipoImovel($tipoImovel): void + { + $this->tipoImovel = $tipoImovel; + } + + /** + * @return mixed + */ + public function getDtCadastro() + { + return $this->dtCadastro; + } + + /** + * @param mixed $dtCadastro + */ + public function setDtCadastro($dtCadastro): void + { + $this->dtCadastro = $dtCadastro; + } + + /** + * @return mixed + */ + public function getEndereco() + { + return $this->endereco; + } + + /** + * @param mixed $endereco + */ + public function setEndereco($endereco): void + { + $this->endereco = $endereco; + } + +// /** +// * @ORM\OneToMany(targetEntity="Entity\contratoLocacao", mappedBy="imovel") +// */ +// private $contratoLocacao; +// +// /** +// * @ORM\OneToMany(targetEntity="Entity\ContratoAdm", mappedBy="imovel") +// */ +// private $contratoAdm; +} \ No newline at end of file diff --git a/Entity/Usuario.php b/Entity/Usuario.php new file mode 100644 index 0000000..d697311 --- /dev/null +++ b/Entity/Usuario.php @@ -0,0 +1,246 @@ +id; + } + + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + + /** + * @return mixed + */ + public function getNome() + { + return $this->nome; + } + + /** + * @param mixed $nome + */ + public function setNome($nome): void + { + $this->nome = $nome; + } + + /** + * @return mixed + */ + public function getCpfCnpj() + { + return $this->cpfCnpj; + } + + /** + * @param mixed $cpfCnpj + */ + public function setCpfCnpj($cpfCnpj): void + { + $this->cpfCnpj = $cpfCnpj; + } + + /** + * @return mixed + */ + public function getDtNascimento() + { + return $this->dtNascimento; + } + + /** + * @param mixed $dtNascimento + */ + public function setDtNascimento($dtNascimento): void + { + $this->dtNascimento = $dtNascimento; + } + + /** + * @return mixed + */ + public function getDtCadastro() + { + return $this->dtCadastro; + } + + /** + * @param mixed $dtCadastro + */ + public function setDtCadastro($dtCadastro): void + { + $this->dtCadastro = $dtCadastro; + } + + /** + * @return mixed + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param mixed $email + */ + public function setEmail($email): void + { + $this->email = $email; + } + + /** + * @return mixed + */ + public function getSexo() + { + return $this->sexo; + } + + /** + * @param mixed $sexo + */ + public function setSexo($sexo): void + { + $this->sexo = $sexo; + } + + /** + * @return mixed + */ + public function getEndereco() + { + return $this->endereco; + } + + /** + * @param mixed $endereco + */ + public function setEndereco(Endereco $endereco): void + { + $this->endereco = $endereco; + } + + /** + * @return mixed + */ + public function getContratoLocacao() + { + return $this->contratoLocacao; + } + + /** + * @param mixed $contratoLocacao + */ + public function setContratoLocacao($contratoLocacao): void + { + $this->contratoLocacao = $contratoLocacao; + } + + /** + * @return mixed + */ + public function getContratoAdm() + { + return $this->contratoAdm; + } + + /** + * @param mixed $contratoAdm + */ + public function setContratoAdm($contratoAdm): void + { + $this->contratoAdm = $contratoAdm; + } + + /** + * @return string + */ + public function getTipoUsuario(): ?string + { + return $this->tipoUsuario; + } + + /** + * @param string $tipoUsuario + */ + public function setTipoUsuario(string $tipoUsuario): void + { + $this->tipoUsuario = $tipoUsuario; + } +} diff --git a/Repository/CorretorRepository.php b/Repository/CorretorRepository.php new file mode 100644 index 0000000..f426292 --- /dev/null +++ b/Repository/CorretorRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('c') + ->andWhere('c.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('c.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Corretor + { + return $this->createQueryBuilder('c') + ->andWhere('c.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/Repository/UsuarioRepository.php b/Repository/UsuarioRepository.php new file mode 100644 index 0000000..4045096 --- /dev/null +++ b/Repository/UsuarioRepository.php @@ -0,0 +1,30 @@ +getEntityManager(); + $em->persist($usuario); + $em->flush(); + } + +} \ No newline at end of file diff --git a/Security/LoginFormAuthenticator.php b/Security/LoginFormAuthenticator.php new file mode 100644 index 0000000..49433fd --- /dev/null +++ b/Security/LoginFormAuthenticator.php @@ -0,0 +1,95 @@ +entityManager = $entityManager; + $this->urlGenerator = $urlGenerator; + $this->csrfTokenManager = $csrfTokenManager; + $this->passwordEncoder = $passwordEncoder; + } + + public function supports(Request $request) + { + return 'app_login' === $request->attributes->get('_route') + && $request->isMethod('POST'); + } + + public function getCredentials(Request $request) + { + $credentials = [ + 'login' => $request->request->get('login'), + 'password' => $request->request->get('password'), + 'csrf_token' => $request->request->get('_csrf_token'), + ]; + $request->getSession()->set( + Security::LAST_USERNAME, + $credentials['login'] + ); + + return $credentials; + } + + public function getUser($credentials, UserProviderInterface $userProvider) + { + $token = new CsrfToken('authenticate', $credentials['csrf_token']); + if (!$this->csrfTokenManager->isTokenValid($token)) { + throw new InvalidCsrfTokenException(); + } + + $user = $this->entityManager->getRepository(Corretor::class)->findOneBy(['login' => $credentials['login']]); + if (!$user) { + // fail authentication with a custom error + throw new CustomUserMessageAuthenticationException('Login could not be found.'); + } + + return $user; + } + + public function checkCredentials($credentials, UserInterface $user) + { + return $this->passwordEncoder->isPasswordValid($user, $credentials['password']); + } + + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) + { + if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) { + return new RedirectResponse($targetPath); + } + + // For example : return new RedirectResponse($this->urlGenerator->generate('some_route')); + throw new \Exception('TODO: provide a valid redirect inside '.__FILE__); + } + + protected function getLoginUrl() + { + return $this->urlGenerator->generate('app_login'); + } +} diff --git a/Service/UsuarioService.php b/Service/UsuarioService.php new file mode 100644 index 0000000..63db391 --- /dev/null +++ b/Service/UsuarioService.php @@ -0,0 +1,24 @@ +usuarioRepository = $usuarioRepository; + } + + public function salvar(Usuario $usuario) + { + $this->usuarioRepository->salvar($usuario); + } + +} \ No newline at end of file diff --git a/src/Controller/ImobiliariaController.php b/src/Controller/ImobiliariaController.php index 20be8c6..9203e35 100644 --- a/src/Controller/ImobiliariaController.php +++ b/src/Controller/ImobiliariaController.php @@ -1,33 +1,33 @@ -render('index.html.twig'); - - } - - /** - * @Route("dashboard", name="dashboard") - */ - public function dashboard() - { - - return $this->render('imobiliaria.html.twig'); - - } +render('index.html.twig'); + + } + + /** + * @Route("dashboard", name="dashboard") + */ + public function dashboard() + { + + return $this->render('imobiliaria.html.twig'); + + } } \ No newline at end of file diff --git a/src/Controller/ImovelController.php b/src/Controller/ImovelController.php index 5cbf296..a674df8 100644 --- a/src/Controller/ImovelController.php +++ b/src/Controller/ImovelController.php @@ -1,86 +1,86 @@ -createForm(ImovelType::class, $imovel); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $imovel = $form->getData(); - $em = $this->getDoctrine()->getManager(); - $em->persist($imovel); - $em->flush(); - - return $this->redirectToRoute('index'); - } - - return $this->render('imovel_cadastro.html.twig', [ - 'form' => $form->createView() - ]); - - } - - /** - * @Route("/imovel/listar", name="listar_imoveis") - */ - public function listarImoveis() - { - $em = $this->getDoctrine()->getManager(); - $imoveis = $em->getRepository(Imovel::class)->findAll(); - - return $this->render('listar_imoveis.html.twig', [ - 'imoveis' => $imoveis - ]); - } - - /** - * @Route("/imovel/portifolios", name="listar_portifolios") - */ - public function imoveisPortifolios() - { - $em = $this->getDoctrine()->getManager(); - $imoveis = $em->getRepository(Imovel::class)->findAll(); - - return $this->render('listar_portifolios.html.twig', [ - 'imoveis' => $imoveis - ]); - } - - /** - * @Route("/imovel/visualizar/{id}", name="imovel_visualizar") - */ - public function imovelVisualizar(Request $request) - { - $id = $request->get('id'); - $em = $this->getDoctrine()->getManager(); - $imovel = $em->getRepository(Imovel::class)->find($id); - - return $this->render('imovel_visualizar.html.twig', [ - 'imovel' => $imovel - ]); - } - - - +createForm(ImovelType::class, $imovel); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $imovel = $form->getData(); + $em = $this->getDoctrine()->getManager(); + $em->persist($imovel); + $em->flush(); + + return $this->redirectToRoute('index'); + } + + return $this->render('imovel_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + + } + + /** + * @Route("/imovel/listar", name="listar_imoveis") + */ + public function listarImoveis() + { + $em = $this->getDoctrine()->getManager(); + $imoveis = $em->getRepository(Imovel::class)->findAll(); + + return $this->render('listar_imoveis.html.twig', [ + 'imoveis' => $imoveis + ]); + } + + /** + * @Route("/imovel/portifolios", name="listar_portifolios") + */ + public function imoveisPortifolios() + { + $em = $this->getDoctrine()->getManager(); + $imoveis = $em->getRepository(Imovel::class)->findAll(); + + return $this->render('listar_portifolios.html.twig', [ + 'imoveis' => $imoveis + ]); + } + + /** + * @Route("/imovel/visualizar/{id}", name="imovel_visualizar") + */ + public function imovelVisualizar(Request $request) + { + $id = $request->get('id'); + $em = $this->getDoctrine()->getManager(); + $imovel = $em->getRepository(Imovel::class)->find($id); + + return $this->render('imovel_visualizar.html.twig', [ + 'imovel' => $imovel + ]); + } + + + } \ No newline at end of file diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index f05d9f1..9f5c57e 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -1,16 +1,16 @@ -render(); - } - +render(); + } + } \ No newline at end of file diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index 7f28f35..b9c0725 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -1,33 +1,33 @@ -getLastAuthenticationError(); - // last username entered by the user - $lastUsername = $authenticationUtils->getLastUsername(); - - return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); - } - - /** - * @Route("/logout", name="app_logout", methods={"GET"}) - */ - public function logout() - { - // controller can be blank: it will never be executed! - throw new \Exception('Don\'t forget to activate logout in security.yaml'); - } -} +getLastAuthenticationError(); + // last username entered by the user + $lastUsername = $authenticationUtils->getLastUsername(); + + return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); + } + + /** + * @Route("/logout", name="app_logout", methods={"GET"}) + */ + public function logout() + { + // controller can be blank: it will never be executed! + throw new \Exception('Don\'t forget to activate logout in security.yaml'); + } +} diff --git a/src/Controller/UsuarioController.php b/src/Controller/UsuarioController.php index f1facd9..91cd16b 100644 --- a/src/Controller/UsuarioController.php +++ b/src/Controller/UsuarioController.php @@ -1,114 +1,115 @@ -createForm(UsuarioType::class, $usuario); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $usuario = $form->getData(); - $em = $this->getDoctrine()->getManager(); - $em->persist($usuario); - $em->flush(); - - return $this->redirectToRoute('index'); - } - - return $this->render('usuario_cadastro.html.twig', [ - 'form' => $form->createView() - ]); - } - - /** - * @Route("/listar", name="listar_usuarios") - */ - public function listarUsuarios(Request $request) - { - $user = new Corretor(); - $user->setLogin('helio'); - $user->setRoles([true ? 'ROLE_ADMIN' : 'ROLE_USER']); - - $user->setPassword('ZkCCqGmNQXOeL1avsq2OWv2BSKLqHE33c2aolQ1nFxg'); - $em = $this->getDoctrine()->getManager(); - $em->persist($user); - $em->flush(); - - - - $em = $this->getDoctrine()->getManager(); - $usuarios = $em->getRepository(Usuario::class)->findAll(); - - return $this->render('listar_usuarios.html.twig', [ - 'usuarios' => $usuarios - ]); - } - - /** - * @Route("/editar/{id}", name="editar_usuario") - */ - public function editarUsuario(int $id, Request $request) - { - $em = $this->getDoctrine()->getManager(); - $usuario = $em->getRepository(Usuario::class)->find($id); - - if (!$usuario) { - throw new \Exception('Usuario não encontrado'); - } - - $form = $this->createForm(UsuarioType::class, $usuario); - - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $usuario = $form->getData(); - $em = $this->getDoctrine()->getManager(); - $em->merge($usuario); - $em->flush(); - - return $this->redirectToRoute('listar_usuarios'); - } - - return $this->render('usuario_cadastro.html.twig', [ - 'form' => $form->createView() - ]); - } - - /** - * @Route("/deletar/{id}", name="deletar_usuario") - */ - public function deletarUsuario(int $id, Request $request) - { - $em = $this->getDoctrine()->getManager(); - $usuario = $em->getRepository(Usuario::class)->find($id); - $em->remove($usuario); - $em->flush(); - $this->addFlash('success', 'Usuario de id:'.$id.' deletado com sucesso!!!'); - - return $this->redirectToRoute('listar_usuarios'); - } -} +createForm(UsuarioType::class, $usuario); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $usuario = $form->getData(); + /*$em = $this->getDoctrine()->getManager(); + $em->persist($usuario); + $em->flush();*/ + $usuarioservice->salvar($usuario); + + return $this->redirectToRoute('index'); + } + + return $this->render('usuario_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + } + + /** + * @Route("/listar", name="listar_usuarios") + */ + public function listarUsuarios(Request $request) + { + $user = new Corretor(); + $user->setLogin('helio'); + $user->setRoles([true ? 'ROLE_ADMIN' : 'ROLE_USER']); + + $user->setPassword('ZkCCqGmNQXOeL1avsq2OWv2BSKLqHE33c2aolQ1nFxg'); + $em = $this->getDoctrine()->getManager(); + $em->persist($user); + $em->flush(); + + + + $em = $this->getDoctrine()->getManager(); + $usuarios = $em->getRepository(Usuario::class)->findAll(); + + return $this->render('listar_usuarios.html.twig', [ + 'usuarios' => $usuarios + ]); + } + + /** + * @Route("/editar/{id}", name="editar_usuario") + */ + public function editarUsuario(int $id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $usuario = $em->getRepository(Usuario::class)->find($id); + + if (!$usuario) { + throw new \Exception('Usuario não encontrado'); + } + + $form = $this->createForm(UsuarioType::class, $usuario); + + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $usuario = $form->getData(); + $em = $this->getDoctrine()->getManager(); + $em->merge($usuario); + $em->flush(); + + return $this->redirectToRoute('listar_usuarios'); + } + + return $this->render('usuario_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + } + + /** + * @Route("/deletar/{id}", name="deletar_usuario") + */ + public function deletarUsuario(int $id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $usuario = $em->getRepository(Usuario::class)->find($id); + $em->remove($usuario); + $em->flush(); + $this->addFlash('success', 'Usuario de id:'.$id.' deletado com sucesso!!!'); + + return $this->redirectToRoute('listar_usuarios'); + } +} diff --git a/src/Entity/Corretor.php b/src/Entity/Corretor.php index 5292d7b..c96d3c6 100644 --- a/src/Entity/Corretor.php +++ b/src/Entity/Corretor.php @@ -1,113 +1,113 @@ -id; - } - - public function getLogin(): ?string - { - return $this->login; - } - - public function setLogin(string $login): self - { - $this->login = $login; - - return $this; - } - - /** - * A visual identifier that represents this user. - * - * @see UserInterface - */ - public function getUsername(): string - { - return (string) $this->login; - } - - /** - * @see UserInterface - */ - public function getRoles(): array - { - $roles = $this->roles; - // guarantee every user at least has ROLE_USER - $roles[] = 'ROLE_USER'; - - return array_unique($roles); - } - - public function setRoles(array $roles): self - { - $this->roles = $roles; - - return $this; - } - - /** - * @see UserInterface - */ - public function getPassword(): string - { - return (string) $this->password; - } - - public function setPassword(string $password): self - { - $this->password = $password; - - return $this; - } - - /** - * @see UserInterface - */ - public function getSalt() - { - // not needed when using the "bcrypt" algorithm in security.yaml - } - - /** - * @see UserInterface - */ - public function eraseCredentials() - { - // If you store any temporary, sensitive data on the user, clear it here - // $this->plainPassword = null; - } -} +id; + } + + public function getLogin(): ?string + { + return $this->login; + } + + public function setLogin(string $login): self + { + $this->login = $login; + + return $this; + } + + /** + * A visual identifier that represents this user. + * + * @see UserInterface + */ + public function getUsername(): string + { + return (string) $this->login; + } + + /** + * @see UserInterface + */ + public function getRoles(): array + { + $roles = $this->roles; + // guarantee every user at least has ROLE_USER + $roles[] = 'ROLE_USER'; + + return array_unique($roles); + } + + public function setRoles(array $roles): self + { + $this->roles = $roles; + + return $this; + } + + /** + * @see UserInterface + */ + public function getPassword(): string + { + return (string) $this->password; + } + + public function setPassword(string $password): self + { + $this->password = $password; + + return $this; + } + + /** + * @see UserInterface + */ + public function getSalt() + { + // not needed when using the "bcrypt" algorithm in security.yaml + } + + /** + * @see UserInterface + */ + public function eraseCredentials() + { + // If you store any temporary, sensitive data on the user, clear it here + // $this->plainPassword = null; + } +} diff --git a/src/Entity/Endereco.php b/src/Entity/Endereco.php index e78e8ea..388caf5 100644 --- a/src/Entity/Endereco.php +++ b/src/Entity/Endereco.php @@ -1,307 +1,307 @@ -id; - } - - /** - * @param mixed $id - */ - public function setId($id): void - { - $this->id = $id; - } - - /** - * @return mixed - */ - public function getLogradouro() - { - return $this->logradouro; - } - - /** - * @param mixed $logradouro - */ - public function setLogradouro($logradouro): void - { - $this->logradouro = $logradouro; - } - - /** - * @return mixed - */ - public function getBairro() - { - return $this->bairro; - } - - /** - * @param mixed $bairro - */ - public function setBairro($bairro): void - { - $this->bairro = $bairro; - } - - /** - * @return mixed - */ - public function getNumero() - { - return $this->numero; - } - - /** - * @param mixed $numero - */ - public function setNumero($numero): void - { - $this->numero = $numero; - } - - /** - * @return mixed - */ - public function getCep() - { - return $this->cep; - } - - /** - * @param mixed $cep - */ - public function setCep($cep): void - { - $this->cep = $cep; - } - - /** - * @return mixed - */ - public function getComplemento() - { - return $this->complemento; - } - - /** - * @param mixed $complemento - */ - public function setComplemento($complemento): void - { - $this->complemento = $complemento; - } - - /** - * @return mixed - */ - public function getCidade() - { - return $this->cidade; - } - - /** - * @param mixed $cidade - */ - public function setCidade($cidade): void - { - $this->cidade = $cidade; - } - - /** - * @return mixed - */ - public function getUf() - { - return $this->uf; - } - - /** - * @param mixed $uf - */ - public function setUf($uf): void - { - $this->uf = $uf; - } - - /** - * @return mixed - */ - public function getTelefone() - { - return $this->telefone; - } - - /** - * @param mixed $telefone - */ - public function setTelefone($telefone): void - { - $this->telefone = $telefone; - } - - /** - * @return mixed - */ - public function getDddTelefone() - { - return $this->dddTelefone; - } - - /** - * @param mixed $dddTelefone - */ - public function setDddTelefone($dddTelefone): void - { - $this->dddTelefone = $dddTelefone; - } - - /** - * @return mixed - */ - public function getCelular() - { - return $this->celular; - } - - /** - * @param mixed $celular - */ - public function setCelular($celular): void - { - $this->celular = $celular; - } - - /** - * @return mixed - */ - public function getDddCelular() - { - return $this->dddCelular; - } - - /** - * @param mixed $dddCelular - */ - public function setDddCelular($dddCelular): void - { - $this->dddCelular = $dddCelular; - } - - /** - * @return mixed - */ - public function getCliente() - { - return $this->cliente; - } - - /** - * @param mixed $cliente - */ - public function setCliente($cliente): void - { - $this->cliente = $cliente; - } - - /** - * @return mixed - */ - public function getImovel() - { - return $this->imovel; - } - - /** - * @param mixed $imovel - */ - public function setImovel($imovel): void - { - $this->imovel = $imovel; - } -} +id; + } + + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + + /** + * @return mixed + */ + public function getLogradouro() + { + return $this->logradouro; + } + + /** + * @param mixed $logradouro + */ + public function setLogradouro($logradouro): void + { + $this->logradouro = $logradouro; + } + + /** + * @return mixed + */ + public function getBairro() + { + return $this->bairro; + } + + /** + * @param mixed $bairro + */ + public function setBairro($bairro): void + { + $this->bairro = $bairro; + } + + /** + * @return mixed + */ + public function getNumero() + { + return $this->numero; + } + + /** + * @param mixed $numero + */ + public function setNumero($numero): void + { + $this->numero = $numero; + } + + /** + * @return mixed + */ + public function getCep() + { + return $this->cep; + } + + /** + * @param mixed $cep + */ + public function setCep($cep): void + { + $this->cep = $cep; + } + + /** + * @return mixed + */ + public function getComplemento() + { + return $this->complemento; + } + + /** + * @param mixed $complemento + */ + public function setComplemento($complemento): void + { + $this->complemento = $complemento; + } + + /** + * @return mixed + */ + public function getCidade() + { + return $this->cidade; + } + + /** + * @param mixed $cidade + */ + public function setCidade($cidade): void + { + $this->cidade = $cidade; + } + + /** + * @return mixed + */ + public function getUf() + { + return $this->uf; + } + + /** + * @param mixed $uf + */ + public function setUf($uf): void + { + $this->uf = $uf; + } + + /** + * @return mixed + */ + public function getTelefone() + { + return $this->telefone; + } + + /** + * @param mixed $telefone + */ + public function setTelefone($telefone): void + { + $this->telefone = $telefone; + } + + /** + * @return mixed + */ + public function getDddTelefone() + { + return $this->dddTelefone; + } + + /** + * @param mixed $dddTelefone + */ + public function setDddTelefone($dddTelefone): void + { + $this->dddTelefone = $dddTelefone; + } + + /** + * @return mixed + */ + public function getCelular() + { + return $this->celular; + } + + /** + * @param mixed $celular + */ + public function setCelular($celular): void + { + $this->celular = $celular; + } + + /** + * @return mixed + */ + public function getDddCelular() + { + return $this->dddCelular; + } + + /** + * @param mixed $dddCelular + */ + public function setDddCelular($dddCelular): void + { + $this->dddCelular = $dddCelular; + } + + /** + * @return mixed + */ + public function getCliente() + { + return $this->cliente; + } + + /** + * @param mixed $cliente + */ + public function setCliente($cliente): void + { + $this->cliente = $cliente; + } + + /** + * @return mixed + */ + public function getImovel() + { + return $this->imovel; + } + + /** + * @param mixed $imovel + */ + public function setImovel($imovel): void + { + $this->imovel = $imovel; + } +} diff --git a/src/Entity/Imovel.php b/src/Entity/Imovel.php index e50f78c..890f5da 100644 --- a/src/Entity/Imovel.php +++ b/src/Entity/Imovel.php @@ -1,173 +1,173 @@ -id; - } - - /** - * @param mixed $id - */ - public function setId($id): void - { - $this->id = $id; - } - - /** - * @return mixed - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param mixed $status - */ - public function setStatus($status): void - { - $this->status = $status; - } - - /** - * @return mixed - */ - public function getCaracteristicas() - { - return $this->caracteristicas; - } - - /** - * @param mixed $caracteristicas - */ - public function setCaracteristicas($caracteristicas): void - { - $this->caracteristicas = $caracteristicas; - } - - /** - * @return mixed - */ - public function getObservacao() - { - return $this->observacao; - } - - /** - * @param mixed $observacao - */ - public function setObservacao($observacao): void - { - $this->observacao = $observacao; - } - - /** - * @return mixed - */ - public function getTipoImovel() - { - return $this->tipoImovel; - } - - /** - * @param mixed $tipoImovel - */ - public function setTipoImovel($tipoImovel): void - { - $this->tipoImovel = $tipoImovel; - } - - /** - * @return mixed - */ - public function getDtCadastro() - { - return $this->dtCadastro; - } - - /** - * @param mixed $dtCadastro - */ - public function setDtCadastro($dtCadastro): void - { - $this->dtCadastro = $dtCadastro; - } - - /** - * @return mixed - */ - public function getEndereco() - { - return $this->endereco; - } - - /** - * @param mixed $endereco - */ - public function setEndereco($endereco): void - { - $this->endereco = $endereco; - } - -// /** -// * @ORM\OneToMany(targetEntity="Entity\contratoLocacao", mappedBy="imovel") -// */ -// private $contratoLocacao; -// -// /** -// * @ORM\OneToMany(targetEntity="Entity\ContratoAdm", mappedBy="imovel") -// */ -// private $contratoAdm; +id; + } + + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + + /** + * @return mixed + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param mixed $status + */ + public function setStatus($status): void + { + $this->status = $status; + } + + /** + * @return mixed + */ + public function getCaracteristicas() + { + return $this->caracteristicas; + } + + /** + * @param mixed $caracteristicas + */ + public function setCaracteristicas($caracteristicas): void + { + $this->caracteristicas = $caracteristicas; + } + + /** + * @return mixed + */ + public function getObservacao() + { + return $this->observacao; + } + + /** + * @param mixed $observacao + */ + public function setObservacao($observacao): void + { + $this->observacao = $observacao; + } + + /** + * @return mixed + */ + public function getTipoImovel() + { + return $this->tipoImovel; + } + + /** + * @param mixed $tipoImovel + */ + public function setTipoImovel($tipoImovel): void + { + $this->tipoImovel = $tipoImovel; + } + + /** + * @return mixed + */ + public function getDtCadastro() + { + return $this->dtCadastro; + } + + /** + * @param mixed $dtCadastro + */ + public function setDtCadastro($dtCadastro): void + { + $this->dtCadastro = $dtCadastro; + } + + /** + * @return mixed + */ + public function getEndereco() + { + return $this->endereco; + } + + /** + * @param mixed $endereco + */ + public function setEndereco($endereco): void + { + $this->endereco = $endereco; + } + +// /** +// * @ORM\OneToMany(targetEntity="Entity\contratoLocacao", mappedBy="imovel") +// */ +// private $contratoLocacao; +// +// /** +// * @ORM\OneToMany(targetEntity="Entity\ContratoAdm", mappedBy="imovel") +// */ +// private $contratoAdm; } \ No newline at end of file diff --git a/src/Entity/Usuario.php b/src/Entity/Usuario.php index 692db37..d697311 100644 --- a/src/Entity/Usuario.php +++ b/src/Entity/Usuario.php @@ -1,246 +1,246 @@ -id; - } - - /** - * @param mixed $id - */ - public function setId($id): void - { - $this->id = $id; - } - - /** - * @return mixed - */ - public function getNome() - { - return $this->nome; - } - - /** - * @param mixed $nome - */ - public function setNome($nome): void - { - $this->nome = $nome; - } - - /** - * @return mixed - */ - public function getCpfCnpj() - { - return $this->cpfCnpj; - } - - /** - * @param mixed $cpfCnpj - */ - public function setCpfCnpj($cpfCnpj): void - { - $this->cpfCnpj = $cpfCnpj; - } - - /** - * @return mixed - */ - public function getDtNascimento() - { - return $this->dtNascimento; - } - - /** - * @param mixed $dtNascimento - */ - public function setDtNascimento($dtNascimento): void - { - $this->dtNascimento = $dtNascimento; - } - - /** - * @return mixed - */ - public function getDtCadastro() - { - return $this->dtCadastro; - } - - /** - * @param mixed $dtCadastro - */ - public function setDtCadastro($dtCadastro): void - { - $this->dtCadastro = $dtCadastro; - } - - /** - * @return mixed - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param mixed $email - */ - public function setEmail($email): void - { - $this->email = $email; - } - - /** - * @return mixed - */ - public function getSexo() - { - return $this->sexo; - } - - /** - * @param mixed $sexo - */ - public function setSexo($sexo): void - { - $this->sexo = $sexo; - } - - /** - * @return mixed - */ - public function getEndereco() - { - return $this->endereco; - } - - /** - * @param mixed $endereco - */ - public function setEndereco(Endereco $endereco): void - { - $this->endereco = $endereco; - } - - /** - * @return mixed - */ - public function getContratoLocacao() - { - return $this->contratoLocacao; - } - - /** - * @param mixed $contratoLocacao - */ - public function setContratoLocacao($contratoLocacao): void - { - $this->contratoLocacao = $contratoLocacao; - } - - /** - * @return mixed - */ - public function getContratoAdm() - { - return $this->contratoAdm; - } - - /** - * @param mixed $contratoAdm - */ - public function setContratoAdm($contratoAdm): void - { - $this->contratoAdm = $contratoAdm; - } - - /** - * @return string - */ - public function getTipoUsuario(): ?string - { - return $this->tipoUsuario; - } - - /** - * @param string $tipoUsuario - */ - public function setTipoUsuario(string $tipoUsuario): void - { - $this->tipoUsuario = $tipoUsuario; - } -} +id; + } + + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + + /** + * @return mixed + */ + public function getNome() + { + return $this->nome; + } + + /** + * @param mixed $nome + */ + public function setNome($nome): void + { + $this->nome = $nome; + } + + /** + * @return mixed + */ + public function getCpfCnpj() + { + return $this->cpfCnpj; + } + + /** + * @param mixed $cpfCnpj + */ + public function setCpfCnpj($cpfCnpj): void + { + $this->cpfCnpj = $cpfCnpj; + } + + /** + * @return mixed + */ + public function getDtNascimento() + { + return $this->dtNascimento; + } + + /** + * @param mixed $dtNascimento + */ + public function setDtNascimento($dtNascimento): void + { + $this->dtNascimento = $dtNascimento; + } + + /** + * @return mixed + */ + public function getDtCadastro() + { + return $this->dtCadastro; + } + + /** + * @param mixed $dtCadastro + */ + public function setDtCadastro($dtCadastro): void + { + $this->dtCadastro = $dtCadastro; + } + + /** + * @return mixed + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param mixed $email + */ + public function setEmail($email): void + { + $this->email = $email; + } + + /** + * @return mixed + */ + public function getSexo() + { + return $this->sexo; + } + + /** + * @param mixed $sexo + */ + public function setSexo($sexo): void + { + $this->sexo = $sexo; + } + + /** + * @return mixed + */ + public function getEndereco() + { + return $this->endereco; + } + + /** + * @param mixed $endereco + */ + public function setEndereco(Endereco $endereco): void + { + $this->endereco = $endereco; + } + + /** + * @return mixed + */ + public function getContratoLocacao() + { + return $this->contratoLocacao; + } + + /** + * @param mixed $contratoLocacao + */ + public function setContratoLocacao($contratoLocacao): void + { + $this->contratoLocacao = $contratoLocacao; + } + + /** + * @return mixed + */ + public function getContratoAdm() + { + return $this->contratoAdm; + } + + /** + * @param mixed $contratoAdm + */ + public function setContratoAdm($contratoAdm): void + { + $this->contratoAdm = $contratoAdm; + } + + /** + * @return string + */ + public function getTipoUsuario(): ?string + { + return $this->tipoUsuario; + } + + /** + * @param string $tipoUsuario + */ + public function setTipoUsuario(string $tipoUsuario): void + { + $this->tipoUsuario = $tipoUsuario; + } +} diff --git a/src/Repository/CorretorRepository.php b/src/Repository/CorretorRepository.php index 79c07f0..f426292 100644 --- a/src/Repository/CorretorRepository.php +++ b/src/Repository/CorretorRepository.php @@ -1,50 +1,50 @@ -createQueryBuilder('c') - ->andWhere('c.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('c.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ - - /* - public function findOneBySomeField($value): ?Corretor - { - return $this->createQueryBuilder('c') - ->andWhere('c.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ -} +createQueryBuilder('c') + ->andWhere('c.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('c.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Corretor + { + return $this->createQueryBuilder('c') + ->andWhere('c.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/UsuarioRepository.php b/src/Repository/UsuarioRepository.php new file mode 100644 index 0000000..4045096 --- /dev/null +++ b/src/Repository/UsuarioRepository.php @@ -0,0 +1,30 @@ +getEntityManager(); + $em->persist($usuario); + $em->flush(); + } + +} \ No newline at end of file diff --git a/src/Service/UsuarioService.php b/src/Service/UsuarioService.php new file mode 100644 index 0000000..63db391 --- /dev/null +++ b/src/Service/UsuarioService.php @@ -0,0 +1,24 @@ +usuarioRepository = $usuarioRepository; + } + + public function salvar(Usuario $usuario) + { + $this->usuarioRepository->salvar($usuario); + } + +} \ No newline at end of file