Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Controller/ImobiliariaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

branch de origem errado

namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

/**
* Class ImobiliariaController
* @package App\Controller
*/
class ImobiliariaController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index()
{

return $this->render('index.html.twig');

}

/**
* @Route("dashboard", name="dashboard")
*/
public function dashboard()
{

return $this->render('imobiliaria.html.twig');

}
}
86 changes: 86 additions & 0 deletions Controller/ImovelController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php


namespace App\Controller;


use App\Entity\Imovel;
use App\Forms\ImovelType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class ImovelController extends AbstractController
{

/**
* @Route("/imovel/cadastro", name="cadasto_imovel")
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function cadastroImovel(Request $request)
{

$imovel = new Imovel();
$form = $this->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
]);
}



}
16 changes: 16 additions & 0 deletions Controller/LoginController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php


namespace App\Controller;


use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class LoginController extends AbstractController
{
public function login()
{
// return $this->render();
}

}
33 changes: 33 additions & 0 deletions Controller/SecurityController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

class SecurityController extends AbstractController
{
/**
* @Route("/login", name="app_login")
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
// get the login error if there is one
$error = $authenticationUtils->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');
}
}
115 changes: 115 additions & 0 deletions Controller/UsuarioController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php


namespace App\Controller;

use App\Entity\Corretor;
use App\Forms\UsuarioType;
use App\Entity\Usuario;
use App\Service\UsuarioService;
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;

/**
* Class UsuarioController
* @package App\Controller
*/
class UsuarioController extends AbstractController
{

/**
* @Route("/usuario", name="usuario_novo")
*/
public function cadastroUsuario(Request $request, UsuarioService $usuarioservice)
{
$usuario = new Usuario();
$form = $this->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');
}
}
Loading