Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
e2c7dea5
Commit
e2c7dea5
authored
Jun 05, 2020
by
alinetenorio
Browse files
Formulário de cadastro de participante
parent
219bac00
Changes
2
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/Auth/RegisterController.php
View file @
e2c7dea5
...
...
@@ -62,13 +62,6 @@ class RegisterController extends Controller
'cpf'
=>
[
'required'
,
'cpf'
],
'celular'
=>
[
'required'
,
'string'
],
'instituicao'
=>
[
'required'
,
'string'
,
'max:255'
],
// 'especProfissional' => [],
'rua'
=>
[
'required'
,
'string'
,
'max:255'
],
'numero'
=>
[
'nullable'
,
'string'
],
'bairro'
=>
[
'required'
,
'string'
,
'max:255'
],
'cidade'
=>
[
'required'
,
'string'
,
'max:255'
],
'uf'
=>
[
'required'
,
'string'
],
'cep'
=>
[
'required'
,
'string'
],
]);
}
...
...
@@ -81,18 +74,6 @@ class RegisterController extends Controller
protected
function
create
(
array
$data
)
{
// endereço
$end
=
new
Endereco
();
$end
->
rua
=
$data
[
'rua'
];
$end
->
numero
=
$data
[
'numero'
];
$end
->
bairro
=
$data
[
'bairro'
];
$end
->
cidade
=
$data
[
'cidade'
];
$end
->
uf
=
$data
[
'uf'
];
$end
->
cep
=
$data
[
'cep'
];
$end
->
save
();
// dd($end)
$user
=
new
User
();
$user
->
name
=
$data
[
'name'
];
$user
->
email
=
$data
[
'email'
];
...
...
@@ -102,7 +83,6 @@ class RegisterController extends Controller
$user
->
instituicao
=
$data
[
'instituicao'
];
$user
->
tipo
=
'participante'
;
$user
->
enderecoId
=
$end
->
id
;
$user
->
save
();
$participante
=
new
Participante
();
...
...
resources/views/auth/register.blade.php
View file @
e2c7dea5
...
...
@@ -94,119 +94,6 @@
</
div
>
</
div
>
<
div
class
=
"row subtitulo"
>
<
div
class
=
"col-sm-12"
>
<
p
>
Endereço
</
p
>
</
div
>
</
div
>
{{
--
Rua
|
Número
|
Bairro
--
}}
<
div
class
=
"form-group row"
>
<
div
class
=
"col-md-2"
>
<
label
for
=
"cep"
class
=
"col-form-label"
>
{{
__
(
'CEP'
)
}}
</
label
>
<
input
value
=
"
{
{old('cep')}
}
"
onblur
=
"pesquisacep(this.value);"
id
=
"cep"
type
=
"text"
required
autocomplete
=
"cep"
name
=
"cep"
autofocus
class
=
"form-control field__input a-field__input"
placeholder
=
"CEP"
size
=
"10"
maxlength
=
"9"
>
@
error
(
'cep'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"form-group row"
>
<
div
class
=
"col-md-6"
>
<
label
for
=
"rua"
class
=
"col-form-label"
>
{{
__
(
'Rua'
)
}}
</
label
>
<
input
value
=
"
{
{old('rua')}
}
"
id
=
"rua"
type
=
"text"
class
=
"form-control @error('rua') is-invalid @enderror"
name
=
"rua"
required
autocomplete
=
"new-password"
>
@
error
(
'rua'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
div
>
<
div
class
=
"col-md-2"
>
<
label
for
=
"numero"
class
=
"col-form-label"
>
{{
__
(
'Número'
)
}}
</
label
>
<
input
value
=
"
{
{old('numero')}
}
"
id
=
"numero"
type
=
"text"
class
=
"form-control @error('numero') is-invalid @enderror"
name
=
"numero"
autocomplete
=
"numero"
>
@
error
(
'numero'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
div
>
<
div
class
=
"col-md-4"
>
<
label
for
=
"bairro"
class
=
"col-form-label"
>
{{
__
(
'Bairro'
)
}}
</
label
>
<
input
value
=
"
{
{old('bairro')}
}
"
id
=
"bairro"
type
=
"text"
class
=
"form-control @error('bairro') is-invalid @enderror"
name
=
"bairro"
required
autocomplete
=
"bairro"
>
@
error
(
'bairro'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"form-group row"
>
<
div
class
=
"col-md-6"
>
<
label
for
=
"cidade"
class
=
"col-form-label"
>
{{
__
(
'Cidade'
)
}}
</
label
>
<
input
value
=
"
{
{old('cidade')}
}
"
id
=
"cidade"
type
=
"text"
class
=
"form-control @error('cidade') is-invalid @enderror"
name
=
"cidade"
required
autocomplete
=
"cidade"
>
@
error
(
'cidade'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
div
>
<
div
class
=
"col-sm-6"
>
<
label
for
=
"uf"
class
=
"col-form-label"
>
{{
__
(
'UF'
)
}}
</
label
>
{{
--
<
input
id
=
"uf"
type
=
"text"
class
=
"form-control @error('uf') is-invalid @enderror"
name
=
"uf"
value
=
"{{ old('uf') }}"
required
autocomplete
=
"uf"
autofocus
>
--
}}
<
select
class
=
"form-control @error('uf') is-invalid @enderror"
id
=
"uf"
name
=
"uf"
>
<
option
value
=
""
disabled
selected
hidden
>--
UF
--</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'AC'
)
selected
@
endif
value
=
"AC"
>
Acre
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'AL'
)
selected
@
endif
value
=
"AL"
>
Alagoas
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'AP'
)
selected
@
endif
value
=
"AP"
>
Amapá
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'AM'
)
selected
@
endif
value
=
"AM"
>
Amazonas
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'BA'
)
selected
@
endif
value
=
"BA"
>
Bahia
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'CE'
)
selected
@
endif
value
=
"CE"
>
Ceará
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'DF'
)
selected
@
endif
value
=
"DF"
>
Distrito
Federal
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'ES'
)
selected
@
endif
value
=
"ES"
>
Espírito
Santo
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'GO'
)
selected
@
endif
value
=
"GO"
>
Goiás
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'MA'
)
selected
@
endif
value
=
"MA"
>
Maranhão
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'MT'
)
selected
@
endif
value
=
"MT"
>
Mato
Grosso
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'MS'
)
selected
@
endif
value
=
"MS"
>
Mato
Grosso
do
Sul
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'MG'
)
selected
@
endif
value
=
"MG"
>
Minas
Gerais
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'PA'
)
selected
@
endif
value
=
"PA"
>
Pará
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'PB'
)
selected
@
endif
value
=
"PB"
>
Paraíba
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'PR'
)
selected
@
endif
value
=
"PR"
>
Paraná
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'PE'
)
selected
@
endif
value
=
"PE"
>
Pernambuco
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'PI'
)
selected
@
endif
value
=
"PI"
>
Piauí
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'RJ'
)
selected
@
endif
value
=
"RJ"
>
Rio
de
Janeiro
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'RN'
)
selected
@
endif
value
=
"RN"
>
Rio
Grande
do
Norte
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'RS'
)
selected
@
endif
value
=
"RS"
>
Rio
Grande
do
Sul
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'RO'
)
selected
@
endif
value
=
"RO"
>
Rondônia
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'RR'
)
selected
@
endif
value
=
"RR"
>
Roraima
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'SC'
)
selected
@
endif
value
=
"SC"
>
Santa
Catarina
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'SP'
)
selected
@
endif
value
=
"SP"
>
São
Paulo
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'SE'
)
selected
@
endif
value
=
"SE"
>
Sergipe
</
option
>
<
option
@
if
(
old
(
'uf'
)
==
'TO'
)
selected
@
endif
value
=
"TO"
>
Tocantins
</
option
>
</
select
>
@
error
(
'uf'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"row justify-content-center"
style
=
"margin: 20px 0 20px 0"
>
<
div
class
=
"col-md-6"
style
=
"padding-left:0"
>
...
...
@@ -226,7 +113,6 @@
@
section
(
'javascript'
)
<
script
type
=
"text/javascript"
>
$
(
document
)
.
ready
(
function
(
$
){
$
(
'#cep'
)
.
mask
(
'00000-000'
);
$
(
'#cpf'
)
.
mask
(
'000.000.000-00'
);
var
SPMaskBehavior
=
function
(
val
)
{
return
val
.
replace
(
/
\
D
/
g
,
''
)
.
length
===
11
?
'(00) 00000-0000'
:
'(00) 0000-00009'
;
...
...
@@ -239,71 +125,5 @@
$
(
'#celular'
)
.
mask
(
SPMaskBehavior
,
spOptions
);
});
function
limpa_formulário_cep
()
{
//Limpa valores do formulário de cep.
document
.
getElementById
(
'rua'
)
.
value
=
(
""
);
document
.
getElementById
(
'bairro'
)
.
value
=
(
""
);
document
.
getElementById
(
'cidade'
)
.
value
=
(
""
);
document
.
getElementById
(
'uf'
)
.
value
=
(
""
);
}
function
meu_callback
(
conteudo
)
{
if
(
!
(
"erro"
in
conteudo
))
{
//Atualiza os campos com os valores.
document
.
getElementById
(
'rua'
)
.
value
=
(
conteudo
.
logradouro
);
document
.
getElementById
(
'bairro'
)
.
value
=
(
conteudo
.
bairro
);
document
.
getElementById
(
'cidade'
)
.
value
=
(
conteudo
.
localidade
);
document
.
getElementById
(
'uf'
)
.
value
=
(
conteudo
.
uf
);
}
//end if.
else
{
//CEP não Encontrado.
limpa_formulário_cep
();
alert
(
"CEP não encontrado."
);
}
}
function
pesquisacep
(
valor
)
{
//Nova variável "cep" somente com dígitos.
var
cep
=
valor
.
replace
(
/
\
D
/
g
,
''
);
//Verifica se campo cep possui valor informado.
if
(
cep
!=
""
)
{
//Expressão regular para validar o CEP.
var
validacep
=
/^
[
0
-
9
]{
8
}
$
/
;
//Valida o formato do CEP.
if
(
validacep
.
test
(
cep
))
{
//Preenche os campos com "..." enquanto consulta webservice.
document
.
getElementById
(
'rua'
)
.
value
=
"..."
;
document
.
getElementById
(
'bairro'
)
.
value
=
"..."
;
document
.
getElementById
(
'cidade'
)
.
value
=
"..."
;
document
.
getElementById
(
'uf'
)
.
value
=
"..."
;
//Cria um elemento javascript.
var
script
=
document
.
createElement
(
'script'
);
//Sincroniza com o callback.
script
.
src
=
'https://viacep.com.br/ws/'
+
cep
+
'/json/?callback=meu_callback'
;
//Insere script no documento e carrega o conteúdo.
document
.
body
.
appendChild
(
script
);
}
//end if.
else
{
//cep é inválido.
limpa_formulário_cep
();
alert
(
"Formato de CEP inválido."
);
}
}
//end if.
else
{
//cep sem valor, limpa formulário.
limpa_formulário_cep
();
}
};
</
script
>
@
endsection
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment