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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
30 changes: 30 additions & 0 deletions src/Controller/ImovelController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;


/**
* Class ImovelController
* @package App\Controller
*/
class ImovelController extends AbstractController
{
/**
* @Route("imovel/cadastro", name="imovel_cadastro")
* @param Request request
*/
public function cadastroImovel(Request $request)
{
$imovel = new Imovel();
$imovel->setStatus("alugado");
$imovel->setEnderecoId();

$em = $this->getDoctrine()->getManager();
$em->persist($imovel);
$em->flush();
}
}
36 changes: 36 additions & 0 deletions src/Controller/UsuarioController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Controller;

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;

/**
* Class UsuarioController
* @package App\Controller
*/
class UsuarioController extends AbstractController
{
/**
* @Route("/usuario", name="usuario_novo")
* @param Request request
*/
public function cadastroUsuario(Request $request, UsuarioService $usuarioService)
{
$usuario = new Usuario();
$form = $this->createForm(UsuarioType::class, $usuario);
$form->handleRequest($request);

$usuarioService = $this->get(UsuarioService::class);

if($form->isSubmitted()) {
$usuario = $form->getData();

}
}

}
24 changes: 14 additions & 10 deletions src/Entity/Endereco.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php
namespace Entity;

namespace App\Entity;

use App\Entity\Usuario;
use App\Entity\Imovel;
use Doctrine\ORM\Mapping as ORM;

/**
Expand Down Expand Up @@ -70,14 +74,14 @@ class Endereco
private $dddCelular;

/**
* @ORM\OneToOne(targetEntity="Entity\Usuario", mappedBy="endereco")
* @ORM\OneToOne(targetEntity="App\Entity\Usuario", mappedBy="endereco")
*/
private $cliente;
private $usuario;

/**
* @ORM\OneToOne(targetEntity="Entity\Imovel", mappedBy="endereco")
* @ORM\OneToOne(targetEntity="App\Entity\Imovel", mappedBy="endereco")
*/
private $imovel;
//private $imovel;

/**
* @return mixed
Expand Down Expand Up @@ -274,17 +278,17 @@ public function setDddCelular($dddCelular): void
/**
* @return mixed
*/
public function getCliente()
public function getUsuario()
{
return $this->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;
}

/**
Expand Down
17 changes: 10 additions & 7 deletions src/Entity/Usuario.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
namespace Entity;

namespace App\Entity;

use App\Entity\Endereco;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\UsuarioRepository")
*/
class Usuario
{
Expand Down Expand Up @@ -55,20 +58,20 @@ class Usuario
private $senha;

/**
* @ORM\OneToOne(targetEntity="Entity\Endereco", inversedBy="cliente")
* @ORM\OneToOne(targetEntity="App\Entity\Endereco", inversedBy="usuario")
* @ORM\JoinColumn(name="endereco_id", referencedColumnName="id", unique=true)
*/
private $endereco;

/**
* @ORM\OneToMany(targetEntity="Entity\contratoLocacao", mappedBy="usuario")
* @ORM\OneToMany(targetEntity="App\Entity\ContratoLocacao", mappedBy="usuario")
*/
private $contratoLocacao;
//private $contratoLocacao;

/**
* @ORM\OneToMany(targetEntity="Entity\ContratoAdm", mappedBy="usuario")
* @ORM\OneToMany(targetEntity="App\Entity\ContratoAdm", mappedBy="usuario")
*/
private $contratoAdm;
//private $contratoAdm;

/**
* @return mixed
Expand Down
136 changes: 136 additions & 0 deletions src/Entity/imovel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php
namespace Entity;

/**
* Class Imovel
* @ORM\Entity
* @package App\Entity
*/
class imovel
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
* @ORM\Column(type="string", length=15)
*/
private $status;

/**
* @var string
* @ORM\Column(type="string", length=150)
*/
private $caracteristicas;

/**
* @var string
* @ORM\Column(type="string", length=150)
*/
private $observacao;

/**
* @var string
* @ORM\Column(type="date", nullable="true)
*/
private $dt_cadastro;

/**
* @ORM\OneToOne(targetEntity="Entity\Endereco", inversedBy="imovel")
* @ORM\JoinColumn(name="endereco_id", referencedColumnName="id", unique=true)
*/
private $endereco_id;


/**
* @return mixed
*/
public function getId()
{
return $this->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;
}
}
78 changes: 78 additions & 0 deletions src/Forms/EnderecoType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php


namespace App\Forms;

use App\Entity\Endereco;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Date;

/**
* Class EnderecoType
* @package App\Form
*/
class EnderecoType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
// ->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,
]);
}
}
Loading