Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ext-ctype": "*",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.1",
"sensiolabs/security-checker": "^6.0",
"symfony/asset": "4.2.*",
"symfony/console": "4.2.*",
"symfony/dotenv": "4.2.*",
Expand Down
229 changes: 228 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified data/database.sqlite
Binary file not shown.
47 changes: 47 additions & 0 deletions src/Controller/ImovelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\RepositorioImovel;
use App\Services\ServicoImovel;

class ImovelController extends AbstractController
{
Expand All @@ -19,6 +21,8 @@ class ImovelController extends AbstractController
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/

// $servicoImovel =
public function cadastroImovel(Request $request)
{

Expand Down Expand Up @@ -81,6 +85,49 @@ public function imovelVisualizar(Request $request)
]);
}

/**
* @Route("/imovel/deletar/{id}", name="deletar_imovel")
*/
public function imovelDeleter(int $id, Request $request)
{
$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->redirectToRoute('listar_imoveis');
}

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

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()
]);
}


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.

linhas em branco desnecessárias

}
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.

Faltando linha em branco no fim do arquivo

1 change: 1 addition & 0 deletions src/Controller/UsuarioController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function listarUsuarios(Request $request)
]);
}


/**
* @Route("/editar/{id}", name="editar_usuario")
*/
Expand Down
Loading