Unverified Commit 2b7850ea authored by Edgar Vinicius Carvalho Vital's avatar Edgar Vinicius Carvalho Vital Committed by GitHub
Browse files

Merge pull request #843 from Edgarvital/master

Tentativa de correção de bug na adição de integrantes da proposta, e correção da validação dos campos na edição do usuário
parents 23132513 c7672936
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
/vendor /vendor
.env .env
.env.backup .env.backup
.idea
.phpunit.result.cache .phpunit.result.cache
Homestead.json Homestead.json
Homestead.yaml Homestead.yaml
......
...@@ -75,7 +75,6 @@ class UserController extends Controller ...@@ -75,7 +75,6 @@ class UserController extends Controller
$id = Auth()->user()->id; $id = Auth()->user()->id;
$user = User::find($id); $user = User::find($id);
if ($request->tipo != "proponente") { if ($request->tipo != "proponente") {
$validated = $request->validate([ $validated = $request->validate([
'name' => ['required', 'string', 'max:255'], 'name' => ['required', 'string', 'max:255'],
'instituicao' => ['required_if:instituicaoSelect,Outra', 'max:255'], 'instituicao' => ['required_if:instituicaoSelect,Outra', 'max:255'],
...@@ -83,21 +82,6 @@ class UserController extends Controller ...@@ -83,21 +82,6 @@ class UserController extends Controller
'celular' => ['required', 'string'], 'celular' => ['required', 'string'],
'cpf' => ['required', 'cpf'], 'cpf' => ['required', 'cpf'],
]); ]);
} else if ($user->tipo == 'participante') {
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'cpf' => ['required', 'cpf', 'unique:users'],
'rg' => ['required', 'unique:participantes'],
'celular' => ['required', 'string', 'telefone'],
'instituicao' => ['required_if:instituicaoSelect,Outra', 'max:255'],
'instituicaoSelect' => ['required_without:instituicao'],
'outroCursoEstudante' => ['required_if:cursoEstudante,Outro', 'max:255'],
'cursoEstudante' => ['required_without:outroCursoEstudante'],
'perfil' => ['required'],
'linkLattes' => ['required'],
]);
} else { } else {
$validated = $request->validate([ $validated = $request->validate([
'name' => ['required', 'string', 'max:255'], 'name' => ['required', 'string', 'max:255'],
...@@ -126,6 +110,24 @@ class UserController extends Controller ...@@ -126,6 +110,24 @@ class UserController extends Controller
]); ]);
} }
if ($user->tipo == 'participante') {
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required_if:alterarSenhaCheckBox,on', 'string', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
'password' => ['required_if:alterarSenhaCheckBox,on', 'string', 'min:8', 'confirmed'],
'cpf' => ['required', 'cpf', Rule::unique('users')->ignore($user->id)],
'rg' => ['required', Rule::unique('participantes')->ignore($user->participantes->first()->id)],
'celular' => ['required', 'string', 'telefone'],
'instituicao' => ['required_if:instituicaoSelect,Outra', 'max:255'],
'instituicaoSelect' => ['required_without:instituicao'],
'outroCursoEstudante' => ['required_if:cursoEstudante,Outro', 'max:255'],
'cursoEstudante' => ['required_without:outroCursoEstudante'],
'perfil' => ['required'],
'linkLattes' => ['required', 'url'],
]);
}
if ($request->alterarSenhaCheckBox != null) { if ($request->alterarSenhaCheckBox != null) {
if (!(Hash::check($request->senha_atual, $user->password))) { if (!(Hash::check($request->senha_atual, $user->password))) {
return redirect()->back()->withErrors(['senha_atual' => 'Senha atual não correspondente']); return redirect()->back()->withErrors(['senha_atual' => 'Senha atual não correspondente']);
...@@ -290,5 +292,5 @@ class UserController extends Controller ...@@ -290,5 +292,5 @@ class UserController extends Controller
'cursoPart' => $cursoPart, 'cursoPart' => $cursoPart,
'areaTematica' => $areaTematica 'areaTematica' => $areaTematica
]); ]);
} }
} }
...@@ -220,32 +220,55 @@ ...@@ -220,32 +220,55 @@
document.getElementById(`celular${modal_id}`).value = data[0]['celular']; document.getElementById(`celular${modal_id}`).value = data[0]['celular'];
document.getElementById(`celular${modal_id}`).setAttribute("readonly", ""); document.getElementById(`celular${modal_id}`).setAttribute("readonly", "");
document.getElementById(`cep${modal_id}`).value = data[3]['cep']; if (data?.[3]?.cep) {
document.getElementById(`cep${modal_id}`).value = data[3].cep;
document.getElementById(`cep${modal_id}`).setAttribute("readonly", ""); document.getElementById(`cep${modal_id}`).setAttribute("readonly", "");
}
if (data?.[3]?.cep) {
document.getElementById(`cep${modal_id}`).value = data[3].cep;
document.getElementById(`cep${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`uf${modal_id}`).value = data[3]['uf']; if (data?.[3]?.uf) {
document.getElementById(`uf${modal_id}`).value = data[3].uf;
document.getElementById(`uf${modal_id}`).setAttribute("readonly", ""); document.getElementById(`uf${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`cidade${modal_id}`).value = data[3]['cidade']; if (data?.[3]?.cidade) {
document.getElementById(`cidade${modal_id}`).value = data[3].cidade;
document.getElementById(`cidade${modal_id}`).setAttribute("readonly", ""); document.getElementById(`cidade${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`bairro${modal_id}`).value = data[3]['bairro']; if (data?.[3]?.bairro) {
document.getElementById(`bairro${modal_id}`).value = data[3].bairro;
document.getElementById(`bairro${modal_id}`).setAttribute("readonly", ""); document.getElementById(`bairro${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`rua${modal_id}`).value = data[3]['rua']; if (data?.[3]?.rua) {
document.getElementById(`rua${modal_id}`).value = data[3].rua;
document.getElementById(`rua${modal_id}`).setAttribute("readonly", ""); document.getElementById(`rua${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`numero${modal_id}`).value = data[3]['numero']; if (data?.[3]?.numero) {
document.getElementById(`numero${modal_id}`).value = data[3].numero;
document.getElementById(`numero${modal_id}`).setAttribute("readonly", ""); document.getElementById(`numero${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`complemento${modal_id}`).value = data[3]['complemento']; if (data?.[3]?.complemento) {
document.getElementById(`complemento${modal_id}`).value = data[3].complemento;
document.getElementById(`complemento${modal_id}`).setAttribute("readonly", ""); document.getElementById(`complemento${modal_id}`).setAttribute("readonly", "");
}
document.getElementById(`instituicao[${modal_id}]`).value = data[0]['instituicao']; if (data?.[0]?.instituicao) {
document.getElementById(`instituicao[${modal_id}]`).value = data[0].instituicao;
document.getElementById(`instituicao[${modal_id}]`).setAttribute("readonly", ""); document.getElementById(`instituicao[${modal_id}]`).setAttribute("readonly", "");
}
document.getElementById(`curso[${modal_id}]`).value = data[2]['curso']; if (data?.[2]?.curso) {
document.getElementById(`curso[${modal_id}]`).value = data[2].curso;
document.getElementById(`curso[${modal_id}]`).setAttribute("readonly", ""); document.getElementById(`curso[${modal_id}]`).setAttribute("readonly", "");
}
console.log(document.getElementById(`funcaoParticipante${modal_id}`)); console.log(document.getElementById(`funcaoParticipante${modal_id}`));
document.getElementById(`funcaoParticipante${modal_id}`).value = data[1]['nome']; document.getElementById(`funcaoParticipante${modal_id}`).value = data[1]['nome'];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment