diff --git a/.gitignore b/.gitignore index 363ca2d2ecbb4be381f1bfd50abbedcd3fdd8795..dd316cd8923e9a6f15a8123246a441695a5e3be2 100755 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /vendor .env .env.backup +.idea .phpunit.result.cache Homestead.json Homestead.yaml diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index a3a7cd73f29f75f59bbaad35114fd6494e51fedb..b743ed5aa3f586b2f212e120ac79ffe6ed5b5ba5 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -75,7 +75,6 @@ class UserController extends Controller $id = Auth()->user()->id; $user = User::find($id); if ($request->tipo != "proponente") { - $validated = $request->validate([ 'name' => ['required', 'string', 'max:255'], 'instituicao' => ['required_if:instituicaoSelect,Outra', 'max:255'], @@ -83,21 +82,6 @@ class UserController extends Controller 'celular' => ['required', 'string'], '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 { $validated = $request->validate([ 'name' => ['required', 'string', 'max:255'], @@ -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 (!(Hash::check($request->senha_atual, $user->password))) { return redirect()->back()->withErrors(['senha_atual' => 'Senha atual não correspondente']); @@ -135,13 +137,13 @@ class UserController extends Controller return redirect()->back()->withErrors(['nova_senha' => 'Senhas diferentes']); } } - + if($user->avaliadors != null && $request->area != null && $user->tipo == "avaliador"){ - $avaliador = Avaliador::where('user_id', '=', $id)->first(); - $avaliador->user_id = $user->id; - //$avaliador->area_id = $request->area; - $avaliador->naturezas()->sync($request->natureza); - $avaliador->update(); + $avaliador = Avaliador::where('user_id', '=', $id)->first(); + $avaliador->user_id = $user->id; + //$avaliador->area_id = $request->area; + $avaliador->naturezas()->sync($request->natureza); + $avaliador->update(); } @@ -259,7 +261,7 @@ class UserController extends Controller if($user->endereco()->first() == null){ $endereco = Endereco::create(); $endereco->user()->save($user); - + } if ($user->participantes()->exists() && $user->participantes()->first()->curso_id) @@ -290,5 +292,5 @@ class UserController extends Controller 'cursoPart' => $cursoPart, 'areaTematica' => $areaTematica ]); -} + } } diff --git a/resources/views/evento/formulario/integrantes.blade.php b/resources/views/evento/formulario/integrantes.blade.php index 70dbf92b196e39b5330725569b82593281ae186c..28aac2a01587743e027d21e1ed46a8f107a8f2c2 100644 --- a/resources/views/evento/formulario/integrantes.blade.php +++ b/resources/views/evento/formulario/integrantes.blade.php @@ -216,40 +216,63 @@ document.getElementById(`rg${modal_id}`).value = data[2]['rg']; document.getElementById(`rg${modal_id}`).setAttribute("readonly", ""); - + document.getElementById(`celular${modal_id}`).value = data[0]['celular']; document.getElementById(`celular${modal_id}`).setAttribute("readonly", ""); - document.getElementById(`cep${modal_id}`).value = data[3]['cep']; - 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']; - document.getElementById(`uf${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(`cidade${modal_id}`).value = data[3]['cidade']; - document.getElementById(`cidade${modal_id}`).setAttribute("readonly", ""); - - document.getElementById(`bairro${modal_id}`).value = data[3]['bairro']; - document.getElementById(`bairro${modal_id}`).setAttribute("readonly", ""); + if (data?.[3]?.uf) { + document.getElementById(`uf${modal_id}`).value = data[3].uf; + document.getElementById(`uf${modal_id}`).setAttribute("readonly", ""); + } - document.getElementById(`rua${modal_id}`).value = data[3]['rua']; - document.getElementById(`rua${modal_id}`).setAttribute("readonly", ""); - - document.getElementById(`numero${modal_id}`).value = data[3]['numero']; - document.getElementById(`numero${modal_id}`).setAttribute("readonly", ""); - - document.getElementById(`complemento${modal_id}`).value = data[3]['complemento']; - document.getElementById(`complemento${modal_id}`).setAttribute("readonly", ""); - - document.getElementById(`instituicao[${modal_id}]`).value = data[0]['instituicao']; - document.getElementById(`instituicao[${modal_id}]`).setAttribute("readonly", ""); + if (data?.[3]?.cidade) { + document.getElementById(`cidade${modal_id}`).value = data[3].cidade; + document.getElementById(`cidade${modal_id}`).setAttribute("readonly", ""); + } + + if (data?.[3]?.bairro) { + document.getElementById(`bairro${modal_id}`).value = data[3].bairro; + document.getElementById(`bairro${modal_id}`).setAttribute("readonly", ""); + } + + if (data?.[3]?.rua) { + document.getElementById(`rua${modal_id}`).value = data[3].rua; + document.getElementById(`rua${modal_id}`).setAttribute("readonly", ""); + } + + if (data?.[3]?.numero) { + document.getElementById(`numero${modal_id}`).value = data[3].numero; + document.getElementById(`numero${modal_id}`).setAttribute("readonly", ""); + } + + if (data?.[3]?.complemento) { + document.getElementById(`complemento${modal_id}`).value = data[3].complemento; + document.getElementById(`complemento${modal_id}`).setAttribute("readonly", ""); + } + + if (data?.[0]?.instituicao) { + document.getElementById(`instituicao[${modal_id}]`).value = data[0].instituicao; + document.getElementById(`instituicao[${modal_id}]`).setAttribute("readonly", ""); + } + + 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}]`).value = data[2]['curso']; - document.getElementById(`curso[${modal_id}]`).setAttribute("readonly", ""); - console.log(document.getElementById(`funcaoParticipante${modal_id}`)); document.getElementById(`funcaoParticipante${modal_id}`).value = data[1]['nome']; - + if(data[1].nome != "Bolsista" && data[1].nome != "Voluntário"){ document.getElementById(`plano-titulo${modal_id}`).setAttribute('hidden', ""); document.getElementById(`plano-nome${modal_id}`).setAttribute('hidden', "");