diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6b4fef --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# imobiliaria + +Requeriments + + • Install PHP 7.2.5 or higher and these PHP extensions (which are installed and enabled by default in most PHP 7 installations): Ctype, iconv, JSON, PCRE, Session, SimpleXML, and Tokenizer; + • Install Composer, which is used to install PHP packages; + • Install Symfony, which creates in your computer a binary called symfony that provides all the tools you need to develop your application locally. + +How to run + +1. Clone the repository. + +2. Install the composer: + +Install ubuntu: + php composer-setup.php --install-dir=bin –filename=composer mv composer.phar /usr/local/bin/composer + +Install windows: + https://getcomposer.org/Composer-Setup.exe + +Install Mac: + curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/ + + +3. Run the application + + symfony server:start php bin/console server:start 0.0.0.0:8000 diff --git a/composer.json b/composer.json index d94ecbe..1243522 100755 --- a/composer.json +++ b/composer.json @@ -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.*", diff --git a/composer.lock b/composer.lock index 5c2ef6d..e6aa6f6 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c5f7fa86ada957082d10d9e8bc1b7adc", + "content-hash": "1f6839c73a44c63da753c23e68943556", "packages": [ { "name": "doctrine/annotations", @@ -2021,6 +2021,54 @@ ], "time": "2019-04-10T06:00:20+00:00" }, + { + "name": "sensiolabs/security-checker", + "version": "v6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/security-checker.git", + "reference": "ce8d0552dcb8d3677ab9adb6d19a5837949bfec4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/ce8d0552dcb8d3677ab9adb6d19a5837949bfec4", + "reference": "ce8d0552dcb8d3677ab9adb6d19a5837949bfec4", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/console": "^2.8|^3.4|^4.2", + "symfony/http-client": "^4.3", + "symfony/mime": "^4.3", + "symfony/polyfill-ctype": "^1.11" + }, + "bin": [ + "security-checker" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0-dev" + } + }, + "autoload": { + "psr-4": { + "SensioLabs\\Security\\": "SensioLabs/Security" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" + } + ], + "description": "A security checker for your composer.lock", + "time": "2019-06-08T06:46:26+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.2.1", @@ -3169,6 +3217,68 @@ "homepage": "https://symfony.com", "time": "2019-05-22T18:38:35+00:00" }, + { + "name": "symfony/http-client", + "version": "v4.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client.git", + "reference": "fec81f1da93f50334085b00113d2fb6f34efc801" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client/zipball/fec81f1da93f50334085b00113d2fb6f34efc801", + "reference": "fec81f1da93f50334085b00113d2fb6f34efc801", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/log": "^1.0", + "symfony/http-client-contracts": "^1.1", + "symfony/polyfill-php73": "^1.11" + }, + "provide": { + "psr/http-client-implementation": "1.0", + "symfony/http-client-implementation": "1.1" + }, + "require-dev": { + "nyholm/psr7": "^1.0", + "psr/http-client": "^1.0", + "symfony/http-kernel": "^4.3", + "symfony/process": "^4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony HttpClient component", + "homepage": "https://symfony.com", + "time": "2019-05-28T08:25:44+00:00" + }, { "name": "symfony/http-foundation", "version": "v4.2.9", @@ -3445,6 +3555,65 @@ ], "time": "2019-05-09T09:19:46+00:00" }, + { + "name": "symfony/mime", + "version": "v4.3.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/mime.git", + "reference": "ec2c5565de60e03f33d4296a655e3273f0ad1f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/mime/zipball/ec2c5565de60e03f33d4296a655e3273f0ad1f8b", + "reference": "ec2c5565de60e03f33d4296a655e3273f0ad1f8b", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-intl-idn": "^1.10", + "symfony/polyfill-mbstring": "^1.0" + }, + "require-dev": { + "egulias/email-validator": "^2.0", + "symfony/dependency-injection": "~3.4|^4.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Mime\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A library to manipulate MIME messages", + "homepage": "https://symfony.com", + "keywords": [ + "mime", + "mime-type" + ], + "time": "2019-06-04T09:22:54+00:00" + }, { "name": "symfony/monolog-bridge", "version": "v4.2.9", @@ -3892,6 +4061,64 @@ ], "time": "2019-02-06T07:57:58+00:00" }, + { + "name": "symfony/polyfill-php73", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" + }, { "name": "symfony/process", "version": "v4.2.9", diff --git a/data/database.sqlite b/data/database.sqlite index 6804099..46622be 100755 Binary files a/data/database.sqlite and b/data/database.sqlite differ diff --git a/src/Controller/ImovelController.php b/src/Controller/ImovelController.php index 5cbf296..433b03d 100644 --- a/src/Controller/ImovelController.php +++ b/src/Controller/ImovelController.php @@ -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 { @@ -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) { @@ -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() + ]); + } } \ No newline at end of file diff --git a/src/Controller/UsuarioController.php b/src/Controller/UsuarioController.php index f1facd9..0b0444f 100644 --- a/src/Controller/UsuarioController.php +++ b/src/Controller/UsuarioController.php @@ -68,6 +68,7 @@ public function listarUsuarios(Request $request) ]); } + /** * @Route("/editar/{id}", name="editar_usuario") */ diff --git a/src/Entity/ContratoAdm.php b/src/Entity/ContratoAdm.php new file mode 100644 index 0000000..503fb50 --- /dev/null +++ b/src/Entity/ContratoAdm.php @@ -0,0 +1,106 @@ +id; + } + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + /** + * @return mixed + */ + public function getDtCadastro() + { + return $this->dtCadastro; + } + /** + * @param mixed $dtCadastro + */ + public function setDtCadastro($dtCadastro): void + { + $this->dtCadastro = $dtCadastro; + } + /** + * @return mixed + */ + public function getUsuario() + { + return $this->usuario; + } + /** + * @param mixed $usuario + */ + public function setUsuario($usuario): void + { + $this->usuario = $usuario; + } + /** + * @return mixed + */ + public function getImovel() + { + return $this->imovel; + } + /** + * @param mixed $imovel + */ + public function setImovel($imovel): void + { + $this->imovel = $imovel; + } + /** + * @return mixed + */ + /** + * @return mixed + */ + public function getClausulaContratual() + { + return $this->clausulaContratual; + } + /** + * @param mixed $clausula_contratual + */ + public function setClausulaContratual($clausula_contratual): void + { + $this->clausula_contratual = $clausula_contratual; + } +} \ No newline at end of file diff --git a/src/Entity/ContratoLocacao.php b/src/Entity/ContratoLocacao.php new file mode 100644 index 0000000..4e6dc22 --- /dev/null +++ b/src/Entity/ContratoLocacao.php @@ -0,0 +1,157 @@ +id; + } + /** + * @param mixed $id + */ + public function setId($id): void + { + $this->id = $id; + } + /** + * @return mixed + */ + public function getDtCadastro() + { + return $this->dtCadastro; + } + /** + * @param mixed $dtCadastro + */ + public function setDtCadastro($dtCadastro): void + { + $this->dtCadastro = $dtCadastro; + } + /** + * @return mixed + */ + public function getDtValidade() + { + return $this->dtValidade; + } + /** + * @param mixed $dtValidade + */ + public function setDtValidade($dtValidade): void + { + $this->dtValidade = $dtValidade; + } + /** + * @return mixed + */ + public function getFormaPagamento() + { + return $this->formaPagamento; + } + /** + * @param mixed $formaPagamento + */ + public function setFormaPagamento($formaPagamento): void + { + $this->formaPagamento = $formaPagamento; + } + /** + * @return mixed + */ + public function getDtVencimento() + { + return $this->dtVencimento; + } + /** + * @param mixed $dtVencimento + */ + public function setDtVencimento($dtVencimento): void + { + $this->dtVencimento = $dtVencimento; + } + /** + * @return mixed + */ + public function getUsuario() + { + return $this->usuario; + } + /** + * @param mixed $usuario + */ + public function setUsuario($usuario): void + { + $this->usuario = $usuario; + } + /** + * @return mixed + */ + public function getImovel() + { + return $this->imovel; + } + /** + * @param mixed $imovel + */ + public function setImovel($imovel): void + { + $this->imovel = $imovel; + } + /** + * @return mixed + */ + public function getClausulaContratual() + { + return $this->clausulaContratual; + } + /** + * @param mixed $clausulaContratual + */ + public function setClausulaContratual($clausulaContratual): void + { + $this->clausulaContratual = $clausulaContratual; + } +} \ No newline at end of file diff --git a/src/Entity/Imovel.php b/src/Entity/Imovel.php index e50f78c..fe6f2fb 100644 --- a/src/Entity/Imovel.php +++ b/src/Entity/Imovel.php @@ -31,6 +31,18 @@ class Imovel */ private $observacao; + /** + * @ORM\OneToMany(targetEntity="App\Entity\ContratoAdm", mappedBy="imovel") + */ + private $contratoAdm; + + + /** + * @ORM\OneToMany(targetEntity="App\Entity\ContratoLocacao", mappedBy="imovel") + */ + private $contratoLocacao; + + /** * @ORM\Column(type="string",name="tipo_imovel", length=150, nullable=true) */ @@ -45,13 +57,15 @@ class Imovel * @ORM\OneToOne(targetEntity="App\Entity\Endereco", inversedBy="imovel", cascade={"persist"}, fetch="EAGER") * @ORM\JoinColumn(name="id_endereco", referencedColumnName="id", unique=true) */ - private $endereco; + private $endereco; /** * @return mixed */ + + public function getId() { return $this->id; diff --git a/src/Forms/ImovelType.php b/src/Forms/ImovelType.php index 14fb62a..110b1f7 100755 --- a/src/Forms/ImovelType.php +++ b/src/Forms/ImovelType.php @@ -41,10 +41,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('caracteristicas', TextType::class, [ - 'label' => 'Caracterisiticas do Imovel', + 'label' => 'Caracteristicas do Imovel', ]) ->add('observacao', TextType::class, [ - 'label' => 'Observações Geral', + 'label' => 'Observações Gerais', ]) ->add('tipoImovel', ChoiceType::class, [ 'empty_data' => 'Casa', diff --git a/src/Repository/ImovelRepository.php b/src/Repository/ImovelRepository.php new file mode 100644 index 0000000..d245276 --- /dev/null +++ b/src/Repository/ImovelRepository.php @@ -0,0 +1,27 @@ +getEntityManager(); + $em->persist($imovel); + $em->flush(); + } +} \ No newline at end of file diff --git a/templates/imovel_cadastro.html.twig b/templates/imovel_cadastro.html.twig index 9e378da..d487c82 100644 --- a/templates/imovel_cadastro.html.twig +++ b/templates/imovel_cadastro.html.twig @@ -4,22 +4,104 @@