From 674a177a7bce6c084098660498d752b7ff41d172 Mon Sep 17 00:00:00 2001 From: hbg Date: Fri, 7 Jun 2019 21:42:14 -0300 Subject: [PATCH 1/3] hugo --- .env | 2 +- src/Controller/ImovelController.php | 30 ++++++ src/Entity/imovel.php | 136 ++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 src/Controller/ImovelController.php create mode 100644 src/Entity/imovel.php diff --git a/.env b/.env index 764f2c0..7dc4420 100755 --- a/.env +++ b/.env @@ -24,7 +24,7 @@ APP_SECRET=db57d5b20b55689a1519cd62120fe723 # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # Configure your db driver and server_version in config/packages/doctrine.yaml -DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db/database.sqlite +DATABASE_URL=pgsql://postgres:postgres@127.0.0.1:5432/vendas ###< doctrine/doctrine-bundle ### ###> symfony/swiftmailer-bundle ### diff --git a/src/Controller/ImovelController.php b/src/Controller/ImovelController.php new file mode 100644 index 0000000..dfcc38e --- /dev/null +++ b/src/Controller/ImovelController.php @@ -0,0 +1,30 @@ +setStatus("alugado"); + $imovel->setEnderecoId(); + + $em = $this->getDoctrine()->getManager(); + $em->persist($imovel); + $em->flush(); + } +} \ No newline at end of file diff --git a/src/Entity/imovel.php b/src/Entity/imovel.php new file mode 100644 index 0000000..1f12819 --- /dev/null +++ b/src/Entity/imovel.php @@ -0,0 +1,136 @@ +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 getDtCadastro() + { + return $this->dt_cadastro; + } + + /** + * @param mixed $dt_cadastro + */ + public function setDtCadastro($dt_cadastro): void + { + $this->dt_cadastro = $dt_cadastro; + } + + /** + * @return mixed + */ + public function getEnderecoId() + { + return $this->endereco_id; + } + + /** + * @param mixed $endereco_id + */ + public function setEnderecoId($endereco_id): void + { + $this->endereco_id = $endereco_id; + } +} \ No newline at end of file From 726cc8cc398f1214d2826cc7bf968911f8fcda19 Mon Sep 17 00:00:00 2001 From: hbg Date: Sat, 8 Jun 2019 11:44:18 -0300 Subject: [PATCH 2/3] another commit --- src/Controller/UsuarioController.php | 35 ++++++++++++++++++++++++++++ src/Entity/Usuario.php | 2 +- src/Repository/UsuarioRepository.php | 27 +++++++++++++++++++++ src/Service/UsuarioService.php | 27 +++++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/Controller/UsuarioController.php create mode 100644 src/Repository/UsuarioRepository.php create mode 100644 src/Service/UsuarioService.php diff --git a/src/Controller/UsuarioController.php b/src/Controller/UsuarioController.php new file mode 100644 index 0000000..6b79ef4 --- /dev/null +++ b/src/Controller/UsuarioController.php @@ -0,0 +1,35 @@ +createForm(UsuarioType::class, $usuario); + $form->handleRequest($request); + + $usuarioService = $this->get(UsuarioService::class); + + if($form->isSubmitted()) { + $usuario = $form->getData(); + + } + } + +} \ No newline at end of file diff --git a/src/Entity/Usuario.php b/src/Entity/Usuario.php index 67a8780..0cdc120 100644 --- a/src/Entity/Usuario.php +++ b/src/Entity/Usuario.php @@ -3,7 +3,7 @@ use Doctrine\ORM\Mapping as ORM; /** - * @ORM\Entity + * @ORM\Entity(RepositoryClass="App\Repository\UsuarioRepository") */ class Usuario { diff --git a/src/Repository/UsuarioRepository.php b/src/Repository/UsuarioRepository.php new file mode 100644 index 0000000..b5df1c5 --- /dev/null +++ b/src/Repository/UsuarioRepository.php @@ -0,0 +1,27 @@ +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..2397b0f --- /dev/null +++ b/src/Service/UsuarioService.php @@ -0,0 +1,27 @@ +usuarioRepository = $usuarioRepository; + } + + public function salvar(Usuario $usuario) + { + $this->usuarioRepository->salvar($usuario); + } +} \ No newline at end of file From 94ca6efcdad0ceb87da9ddb55010290688569856 Mon Sep 17 00:00:00 2001 From: hbg Date: Sat, 8 Jun 2019 15:25:30 -0300 Subject: [PATCH 3/3] final commit, Hugo, 08/06 --- src/Controller/UsuarioController.php | 1 + src/Entity/Endereco.php | 24 +++++---- src/Entity/Usuario.php | 17 +++--- src/Forms/EnderecoType.php | 78 ++++++++++++++++++++++++++++ src/Forms/UsuarioType.php | 72 +++++++++++++++++++++++++ src/Service/UsuarioService.php | 1 + 6 files changed, 176 insertions(+), 17 deletions(-) create mode 100644 src/Forms/EnderecoType.php create mode 100644 src/Forms/UsuarioType.php diff --git a/src/Controller/UsuarioController.php b/src/Controller/UsuarioController.php index 6b79ef4..00933d3 100644 --- a/src/Controller/UsuarioController.php +++ b/src/Controller/UsuarioController.php @@ -4,6 +4,7 @@ use App\Entity\Usuario; use App\Service\UsuarioService; +use App\Forms\UsuarioType; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Entity/Endereco.php b/src/Entity/Endereco.php index a7ce442..cb40419 100644 --- a/src/Entity/Endereco.php +++ b/src/Entity/Endereco.php @@ -1,5 +1,9 @@ cliente; + return $this->usuario; } /** - * @param mixed $cliente + * @param mixed $usuario */ - public function setCliente($cliente): void + public function setUsuario($usuario): void { - $this->cliente = $cliente; + $this->usuario = $usuario; } /** diff --git a/src/Entity/Usuario.php b/src/Entity/Usuario.php index 0cdc120..2de1efe 100644 --- a/src/Entity/Usuario.php +++ b/src/Entity/Usuario.php @@ -1,9 +1,12 @@ setAction('../endereco') +// ->setMethod('POST') + ->add('logradouro', TextType::class, [ + 'label' => 'Logradouro', + ]) + ->add('bairro', TextType::class, [ + 'label' => 'Bairro', + ]) + ->add('numero', TextType::class, [ + 'label' => 'Numero', + ]) + ->add('cep', TextType::class, [ + 'label' => 'CEP', + 'attr' => [ + 'style' => 'width: 200px' + ] + ]) + ->add('complemento', TextType::class, [ + 'label' => 'Complemento', + ]) + ->add('cidade', TextType::class, [ + 'label' => 'Cidade', + ]) + ->add('uf', TextType::class, [ + 'label' => 'UF', + ]) + ->add('telefone', TextType::class, [ + 'label' => 'telefone', + ]) + ->add('ddd', TextType::class, [ + 'label' => 'DDD', + ]) + ->add('celular', TextType::class, [ + 'label' => 'Celular', + ]) + ->add('dddCelular', TextType::class, [ + 'label' => 'DDD', + ]) + ->add('usuario', UsuarioType::class) + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Endereco::class, + ]); + } +} diff --git a/src/Forms/UsuarioType.php b/src/Forms/UsuarioType.php new file mode 100644 index 0000000..198f781 --- /dev/null +++ b/src/Forms/UsuarioType.php @@ -0,0 +1,72 @@ +setAction('../usuario') +// ->setMethod('POST') + ->add('nome', TextType::class, [ + 'label' => 'Nome', + ]) + ->add('cpfCnpj', TextType::class, [ + 'label' => 'Cpf', + 'attr' => [ + 'style' => 'width: 200px', + 'data-mask' => '000.000.000-00', + 'placeholder' => '_ _ _ . _ _ _ . _ _ _ - _ _' + ] + ]) + ->add('sexo', TextType::class, [ + 'label' => 'Sexo', + ]) + ->add('email', EmailType::class, [ + 'label' => 'Email', + ]) + ->add('dtNascimento', DateType::class, [ + 'label' => 'Data de Nascimento', + 'widget' => 'single_text', + 'attr' => ['class' => 'js-datepicker'], + ]) + ->add('dtCadastro', DateType::class, [ + 'label' => 'Data de Cadastro', + 'widget' => 'single_text', + 'attr' => ['class' => 'js-datepicker'], + ]) + ->add('tipoUsuario', TextType::class, [ + 'label' => 'Tipo De usuário', + ]) + ->add('endereco', EnderecoType::class) + ; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Usuario::class, + ]); + } +} diff --git a/src/Service/UsuarioService.php b/src/Service/UsuarioService.php index 2397b0f..f7b96e4 100644 --- a/src/Service/UsuarioService.php +++ b/src/Service/UsuarioService.php @@ -2,6 +2,7 @@ namespace App\Service; +use App\Entity\Usuario; use App\Repository\UsuarioRepository; /**