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
Binary file modified data/database.sqlite
Binary file not shown.
3 changes: 1 addition & 2 deletions src/Command/CreateEnderecosCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace App\Command;


use App\Entity\Endereco;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManager;
Expand Down Expand Up @@ -115,4 +114,4 @@ private function cepRandom()



}
}
6 changes: 1 addition & 5 deletions src/Controller/ImobiliariaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ class ImobiliariaController extends AbstractController
*/
public function index()
{

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

}

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

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

}
}
}
105 changes: 69 additions & 36 deletions src/Controller/ImovelController.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,66 @@
<?php


namespace App\Controller;


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

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

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

$imovel = new Imovel();
$form = $this->createForm(ImovelType::class, $imovel);
$form->handleRequest($request);

if ($form->isSubmitted()) {
$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();
// $em = $this->getDoctrine()->getManager();
// $em->persist($imovel);
// $em->flush();

$imovelService->salvar($imovel);

return $this->redirectToRoute('index');
}
}

return $this->render('imovel_cadastro.html.twig', [
'form' => $form->createView()
]);
return $this->render('imovel_cadastro.html.twig' , [
'form'=>$form->createview()
]
);

}

/**
* @Route("/imovel/listar", name="listar_imoveis")
*/
public function listarImoveis()

public function listarImoveis(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();
$imoveis = $em->getRepository(Imovel::class)->findAll();

Expand All @@ -55,32 +70,50 @@ public function listarImoveis()
}

/**
* @Route("/imovel/portifolios", name="listar_portifolios")
* @Route("/editar/{id}", name="editar_imovel")
*/
public function imoveisPortifolios()
public function editarImovel(int $id, Request $request)
{
$em = $this->getDoctrine()->getManager();
$imoveis = $em->getRepository(Imovel::class)->findAll();
$imovel = $em->getRepository(Imovel::class)->find($id);

return $this->render('listar_portifolios.html.twig', [
'imoveis' => $imoveis
if (!$imovel) {
throw new \Exception('Imovel não encontrado');
}

$form = $this->createForm(ImovelType::class, $imovel);

$form->handleRequest($request);

if ($form->isSubmitted()) {
$imovel = $form->getData();
$em = $this->getDoctrine()->getManager();
$em->merge($imovel);
$em->flush();

return $this->redirectToRoute('listar_imoveis');
}

return $this->render('imovel_cadastro.html.twig', [
'form' => $form->createView()
]);
}

/**
* @Route("/imovel/visualizar/{id}", name="imovel_visualizar")
* @Route("/deletar/{id}", name="deletar_imovel")
*/
public function imovelVisualizar(Request $request)
public function deletarImovel(int $id, Request $request)
{
$id = $request->get('id');
// $imovel = new Imovel();
// $imovel = $this->getRepository(Imovel::class)->find($id);
// $imovelService->deletar($imovel);

$em = $this->getDoctrine()->getManager();
$imovel = $em->getRepository(Imovel::class)->find($id);
$em->remove($imovel);
$em->flush();
$this->addFlash('success', 'Imovel de id:'.$id.' deletado com sucesso!!!');

return $this->render('imovel_visualizar.html.twig', [
'imovel' => $imovel
]);
return $this->redirectToRoute('listar_imoveis');
}



}
}
3 changes: 1 addition & 2 deletions src/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace App\Controller;


use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class LoginController extends AbstractController
Expand All @@ -13,4 +12,4 @@ public function login()
// return $this->render();
}

}
}
1 change: 1 addition & 0 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ public function logout()
throw new \Exception('Don\'t forget to activate logout in security.yaml');
}
}

25 changes: 14 additions & 11 deletions src/Controller/UsuarioController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand All @@ -21,31 +22,32 @@ class UsuarioController extends AbstractController
{

/**
*@IsGranted("ROLE_ADMIN")
* @Route("/usuario", name="usuario_novo")
*/
public function cadastroUsuario(Request $request)
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();
// $em = $this->getDoctrine()->getManager();
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.

Remover comentarios

// $em->persist($usuario);
// $em->flush();

$usuarioService->salvar($usuario);

return $this->redirectToRoute('index');
}

return $this->render('usuario_cadastro.html.twig', [
'form' => $form->createView()
]);
return $this->render('usuario_cadastro.html.twig' , [
'form'=>$form->createview()
]
);
}

/**
* @Route("/listar", name="listar_usuarios")
/**
* @Route("/usuario/listar", name="listar_usuarios")
*/
public function listarUsuarios(Request $request)
{
Expand Down Expand Up @@ -112,3 +114,4 @@ public function deletarUsuario(int $id, Request $request)
return $this->redirectToRoute('listar_usuarios');
}
}

2 changes: 1 addition & 1 deletion src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ private static function mod($dividendo, $divisor): float
{
return round($dividendo - (floor($dividendo / $divisor) * $divisor));
}
}
}
Loading