From 12d84e976c361abc168e91b8dfeafcc60ad9e5eb Mon Sep 17 00:00:00 2001
From: Gabriel-31415 <gabriel.uag.ufrpe@gmail.com>
Date: Thu, 1 Jul 2021 08:18:12 +0000
Subject: [PATCH] submissao e rascunho e visualizar

---
 app/Arquivo.php                               |   2 +-
 app/Http/Controllers/TrabalhoController.php   | 599 ++++++++------
 app/Http/Requests/StoreTrabalho.php           |   2 -
 app/Http/Requests/UpdateTrabalho.php          |  70 +-
 ...2021_07_01_020325_alter_table_arquivos.php |  33 +
 resources/views/componentes/input.blade.php   |   7 +-
 .../views/evento/formulario/anexos.blade.php  |   7 +-
 .../evento/formulario/participantes.blade.php |  11 +-
 .../projeto/editaFormulario/anexos.blade.php  | 155 +++-
 .../editaFormulario/finalizar.blade.php       |   3 +-
 .../editaFormulario/participantes.blade.php   | 736 ++++++++++++++----
 .../projeto/editaFormulario/projeto.blade.php |  32 +-
 .../editaFormulario/proponente.blade.php      |  12 +-
 resources/views/projeto/editar.blade.php      | 333 ++++----
 .../formularioVisualizar/anexos.blade.php     | 117 ++-
 .../participantes.blade.php                   |  17 +-
 .../formularioVisualizar/projeto.blade.php    |   6 +-
 routes/web.php                                |  28 +-
 18 files changed, 1506 insertions(+), 664 deletions(-)
 create mode 100644 database/migrations/2021_07_01_020325_alter_table_arquivos.php

diff --git a/app/Arquivo.php b/app/Arquivo.php
index 665ffce..709ecae 100644
--- a/app/Arquivo.php
+++ b/app/Arquivo.php
@@ -12,7 +12,7 @@ class Arquivo extends Model
    * @var array
    */
   protected $fillable = [
-      'nome', 'versao', 'versaoFinal', 'data', 'trabalhoId', 'participanteId'
+      'nome','titulo', 'versao', 'versaoFinal', 'data', 'trabalhoId', 'participanteId'
   ];
 
   public function trabalho(){
diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php
index facf84c..bcfb700 100644
--- a/app/Http/Controllers/TrabalhoController.php
+++ b/app/Http/Controllers/TrabalhoController.php
@@ -35,6 +35,7 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use App\Http\Requests\StoreTrabalho;
 use Illuminate\Support\Facades\Mail;
+use App\Http\Requests\UpdateTrabalho;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Facades\Validator;
 use App\Mail\EmailParaUsuarioNaoCadastrado;
@@ -233,7 +234,7 @@ class TrabalhoController extends Controller
           }
 
           //Autorização ou Justificativa
-          if( isset($request->anexoComiteEtica)){
+          if( isset($request->anexoAutorizacaoComiteEtica)){
             if(Storage::disk()->exists($trabalho->anexoAutorizacaoComiteEtica)) {
               Storage::delete($trabalho->anexoAutorizacaoComiteEtica);
             }
@@ -391,234 +392,233 @@ class TrabalhoController extends Controller
                                            ]);
     }
 
-    public function update(Request $request, $id)
-    {
-      $mytime = Carbon::now('America/Recife');
-      $mytime = $mytime->toDateString();
-      $evento = Evento::find($request->editalId);
-      $coordenador = CoordenadorComissao::find($evento->coordenadorId);
-      //Relaciona o projeto criado com o proponente que criou o projeto
-      $proponente = Proponente::where('user_id', Auth::user()->id)->first();
-      //$trabalho->proponentes()->save($proponente);
-      //dd($coordenador->id);
-      $trabalho = "trabalho";
-      if($evento->inicioSubmissao > $mytime){
-        if($mytime >= $evento->fimSubmissao){
-            return redirect()->route('home');
-        }
-      }
-
-      //O anexo de Decisão do CONSU dependo do tipo de edital
-      if( $evento->tipo == 'PIBIC' || $evento->tipo == 'PIBIC-EM'){
-
-        $validatedData = $request->validate([
-          'editalId'                => ['required', 'string'],
-          'nomeProjeto'             => ['required', 'string'],
-          'grandeArea'              => ['required', 'string'],
-          'area'                    => ['required', 'string'],
-          'subArea'                 => ['required', 'string'],
-          'pontuacaoPlanilha'       => ['required', 'string'],
-          'linkGrupo'               => ['required', 'string'],
-          'linkLattesEstudante'     => ['required', 'string'],
-          'nomeParticipante.*'      => ['required', 'string'],
-          'emailParticipante.*'     => ['required', 'string'],
-          'funcaoParticipante.*'    => ['required', 'string'],
-        ]);
-
-      }else{
-        //Caso em que o anexo da Decisão do CONSU não necessário
-        $validatedData = $request->validate([
-          'editalId'                => ['required', 'string'],
-          'nomeProjeto'             => ['required', 'string',],
-          'grandeArea'              => ['required', 'string'],
-          'area'                    => ['required', 'string'],
-          'subArea'                 => ['required', 'string'],
-          'pontuacaoPlanilha'       => ['required', 'string'],
-          'linkGrupo'               => ['required', 'string'],
-          'linkLattesEstudante'     => ['required', 'string'],
-          'nomeCoordenador'         => ['required', 'string'],
-          'nomeParticipante.*'      => ['required', 'string'],
-          'emailParticipante.*'     => ['required', 'string'],
-          'funcaoParticipante.*'    => ['required', 'string'],
-        ]);
-      }
-
-      $trabalho = Trabalho::find($id);
-      $trabalho->titulo = $request->nomeProjeto;
-      $trabalho->coordenador_id = $coordenador->id;
-      $trabalho->grande_area_id = $request->grandeArea;
-      $trabalho->area_id = $request->area;
-      $trabalho->sub_area_id = $request->subArea;
-      $trabalho->pontuacaoPlanilha = $request->pontuacaoPlanilha;
-      $trabalho->linkGrupoPesquisa = $request->linkGrupo;
-      $trabalho->linkLattesEstudante = $request->linkLattesEstudante;
-      $trabalho->data = $mytime;
-      $trabalho->evento_id = $request->editalId;
-      $trabalho->proponente_id = $proponente->id;
-
-      $pasta = 'trabalhos/' . $request->editalId . '/' . $trabalho->id;
-
-      if (!(is_null($request->anexoDecisaoCONSU))) {
-        Storage::delete($trabalho->anexoDecisaoCONSU);
-        $trabalho->anexoDecisaoCONSU = Storage::putFileAs($pasta, $request->anexoDecisaoCONSU,  "CONSU.pdf");
-      }
-
-      if (!(is_null($request->anexoProjeto))) {
-        Storage::delete($trabalho->anexoProjeto);
-        $trabalho->anexoProjeto = Storage::putFileAs($pasta, $request->anexoProjeto,  "Projeto.pdf");
-      }
-
-      if (!(is_null($request->anexoComiteEtica))) {
-        Storage::delete($trabalho->anexoComiteEtica);
-        $trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoComiteEtica,  "Comite_de_etica.pdf");
-      }
-
-      if (!(is_null($request->anexoLattesCoordenador))) {
-        Storage::delete($trabalho->anexoLattesCoordenador);
-        $trabalho->anexoLattesCoordenador = Storage::putFileAs($pasta, $request->anexoLattesCoordenador,  "Latter_Coordenador.pdf");
-      }
-
-      if (!(is_null($request->anexoPlanilhaPontuacao))) {
-        Storage::delete($trabalho->anexoLattesCoordenador);
-        $trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilhaPontuacao,  "Planilha.pdf");
-      }
-      //atualizando projeto
-      $trabalho->update();
-
-      // criando novos participantes que podem ter sido adicionados
-      $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get();
-      $users = User::whereIn('id', $participantesUsersIds)->get();
-      $emailParticipantes = [];
-      foreach ($users as $user) {
-        array_push($emailParticipantes, $user->email);
-      }
-      foreach ($request->emailParticipante as $key => $value) {
-        // criando novos participantes que podem ter sido adicionados
-        if (!(in_array($request->emailParticipante[$key], $emailParticipantes, false))) {
-          $userParticipante = User::where('email', $value)->first();
-          if($userParticipante == null){
-            $passwordTemporario = Str::random(8);
-            $subject = "Participante de Projeto";
-            Mail::to($value)->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, '  ', 'Participante', $evento->nome, $passwordTemporario, $subject));
-            $usuario = User::create([
-              'email' => $value,
-              'password' => bcrypt($passwordTemporario),
-              'usuarioTemp' => true,
-              'name' => $request->nomeParticipante[$key],
-              'tipo' => 'participante',
-            ]);
-
-            $participante = new Participante();
-            $participante->user_id = $usuario->id;
-            $participante->trabalho_id = $trabalho->id;
-            $participante->funcao_participante_id = $request->funcaoParticipante[$key];
-            $participante->save();
-
-          }else{
-            $participante = new Participante();
-            $participante->user_id = $userParticipante->id;
-            $participante->trabalho_id = $trabalho->id;
-            $participante->funcao_participante_id = $request->funcaoParticipante[$key];
-            $participante->save();
+    
 
-            $participante->trabalhos()->save($trabalho);
+    // $mytime = Carbon::now('America/Recife');
+    // $mytime = $mytime->toDateString();
+    // $evento = Evento::find($request->editalId);
+    // $coordenador = CoordenadorComissao::find($evento->coordenadorId);
+    // //Relaciona o projeto criado com o proponente que criou o projeto
+    // $proponente = Proponente::where('user_id', Auth::user()->id)->first();
+    // //$trabalho->proponentes()->save($proponente);
+    // //dd($coordenador->id);
+    // $trabalho = "trabalho";
+    // if($evento->inicioSubmissao > $mytime){
+    //   if($mytime >= $evento->fimSubmissao){
+    //       return redirect()->route('home');
+    //   }
+    // }
 
-            $subject = "Participante de Projeto";
-            $email = $value;
-            Mail::to($email)
-                  ->send(new SubmissaoTrabalho($userParticipante, $subject, $evento, $trabalho));
-          }
+    // //O anexo de Decisão do CONSU dependo do tipo de edital
+    // if( $evento->tipo == 'PIBIC' || $evento->tipo == 'PIBIC-EM'){
+
+    //   $validatedData = $request->validate([
+    //     'editalId'                => ['required', 'string'],
+    //     'nomeProjeto'             => ['required', 'string'],
+    //     'grandeArea'              => ['required', 'string'],
+    //     'area'                    => ['required', 'string'],
+    //     'subArea'                 => ['required', 'string'],
+    //     'pontuacaoPlanilha'       => ['required', 'string'],
+    //     'linkGrupo'               => ['required', 'string'],
+    //     'linkLattesEstudante'     => ['required', 'string'],
+    //     'nomeParticipante.*'      => ['required', 'string'],
+    //     'emailParticipante.*'     => ['required', 'string'],
+    //     'funcaoParticipante.*'    => ['required', 'string'],
+    //   ]);
 
-          $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/';
-          $nome =  $request->nomePlanoTrabalho[$key] .".pdf";
-          $file = $request->anexoPlanoTrabalho[$key];
-          Storage::putFileAs($path, $file, $nome);
-
-          $arquivo = new Arquivo();
-          $arquivo->titulo = $request->nomePlanoTrabalho[$key];
-          $arquivo->nome = $path . $nome;
-          $arquivo->trabalhoId = $trabalho->id;
-          $arquivo->data = $mytime;
-          $arquivo->participanteId = $participante->id;
-          $arquivo->versaoFinal = true;
-          $arquivo->save();
-        }
+    // }else{
+    //   //Caso em que o anexo da Decisão do CONSU não necessário
+    //   $validatedData = $request->validate([
+    //     'editalId'                => ['required', 'string'],
+    //     'nomeProjeto'             => ['required', 'string',],
+    //     'grandeArea'              => ['required', 'string'],
+    //     'area'                    => ['required', 'string'],
+    //     'subArea'                 => ['required', 'string'],
+    //     'pontuacaoPlanilha'       => ['required', 'string'],
+    //     'linkGrupo'               => ['required', 'string'],
+    //     'linkLattesEstudante'     => ['required', 'string'],
+    //     'nomeCoordenador'         => ['required', 'string'],
+    //     'nomeParticipante.*'      => ['required', 'string'],
+    //     'emailParticipante.*'     => ['required', 'string'],
+    //     'funcaoParticipante.*'    => ['required', 'string'],
+    //   ]);
+    // }
 
-        //atualizando os participantes que já estão no projeto e planos de trabalho se enviados
-        if (in_array($request->emailParticipante[$key], $emailParticipantes, false)) {
-          $userParticipante = User::where('email', $value)->first();
-          if($userParticipante != null){
+    // $trabalho = Trabalho::find($id);
+    // $trabalho->titulo = $request->nomeProjeto;
+    // $trabalho->coordenador_id = $coordenador->id;
+    // $trabalho->grande_area_id = $request->grandeArea;
+    // $trabalho->area_id = $request->area;
+    // $trabalho->sub_area_id = $request->subArea;
+    // $trabalho->pontuacaoPlanilha = $request->pontuacaoPlanilha;
+    // $trabalho->linkGrupoPesquisa = $request->linkGrupo;
+    // $trabalho->linkLattesEstudante = $request->linkLattesEstudante;
+    // $trabalho->data = $mytime;
+    // $trabalho->evento_id = $request->editalId;
+    // $trabalho->proponente_id = $proponente->id;
+
+    // $pasta = 'trabalhos/' . $request->editalId . '/' . $trabalho->id;
+
+    // if (!(is_null($request->anexoDecisaoCONSU))) {
+    //   Storage::delete($trabalho->anexoDecisaoCONSU);
+    //   $trabalho->anexoDecisaoCONSU = Storage::putFileAs($pasta, $request->anexoDecisaoCONSU,  "CONSU.pdf");
+    // }
 
-            $user = User::where('email', $request->emailParticipante[$key])->first();
-            $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first();
+    // if (!(is_null($request->anexoProjeto))) {
+    //   Storage::delete($trabalho->anexoProjeto);
+    //   $trabalho->anexoProjeto = Storage::putFileAs($pasta, $request->anexoProjeto,  "Projeto.pdf");
+    // }
 
-            $user->name = $request->nomeParticipante[$key];
-            $user->update();
+    // if (!(is_null($request->anexoComiteEtica))) {
+    //   Storage::delete($trabalho->anexoComiteEtica);
+    //   $trabalho->anexoAutorizacaoComiteEtica = Storage::putFileAs($pasta, $request->anexoComiteEtica,  "Comite_de_etica.pdf");
+    // }
 
-            $participante->funcao_participante_id = $request->funcaoParticipante[$key];
-            $participante->update();
+    // if (!(is_null($request->anexoLattesCoordenador))) {
+    //   Storage::delete($trabalho->anexoLattesCoordenador);
+    //   $trabalho->anexoLattesCoordenador = Storage::putFileAs($pasta, $request->anexoLattesCoordenador,  "Latter_Coordenador.pdf");
+    // }
 
-            //atualizando planos de trabalho
-            if ($request->anexoPlanoTrabalho != null && array_key_exists($key, $request->anexoPlanoTrabalho)) {
-              if (!(is_null($request->anexoPlanoTrabalho[$key]))) {
-                $arquivo = Arquivo::where('participanteId', $participante->id)->first();
-                //se plano já existir, deletar
-                if($arquivo != null){
-                  Storage::delete($arquivo->nome);
-                  $arquivo->delete();
-                }
-
-                //atualizar plano
-                if($request->semPlano[$key] == null){
-                  $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/';
-                  $nome =  $request->nomePlanoTrabalho[$key] .".pdf";
-                  $file = $request->anexoPlanoTrabalho[$key];
-                  Storage::putFileAs($path, $file, $nome);
+    // if (!(is_null($request->anexoPlanilhaPontuacao))) {
+    //   Storage::delete($trabalho->anexoLattesCoordenador);
+    //   $trabalho->anexoPlanilhaPontuacao = Storage::putFileAs($pasta, $request->anexoPlanilhaPontuacao,  "Planilha.pdf");
+    // }
+    // //atualizando projeto
+    // $trabalho->update();
+
+    // // criando novos participantes que podem ter sido adicionados
+    // $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get();
+    // $users = User::whereIn('id', $participantesUsersIds)->get();
+    // $emailParticipantes = [];
+    // foreach ($users as $user) {
+    //   array_push($emailParticipantes, $user->email);
+    // }
+    // foreach ($request->emailParticipante as $key => $value) {
+    //   // criando novos participantes que podem ter sido adicionados
+    //   if (!(in_array($request->emailParticipante[$key], $emailParticipantes, false))) {
+    //     $userParticipante = User::where('email', $value)->first();
+    //     if($userParticipante == null){
+    //       $passwordTemporario = Str::random(8);
+    //       $subject = "Participante de Projeto";
+    //       Mail::to($value)->send(new EmailParaUsuarioNaoCadastrado(Auth()->user()->name, '  ', 'Participante', $evento->nome, $passwordTemporario, $subject));
+    //       $usuario = User::create([
+    //         'email' => $value,
+    //         'password' => bcrypt($passwordTemporario),
+    //         'usuarioTemp' => true,
+    //         'name' => $request->nomeParticipante[$key],
+    //         'tipo' => 'participante',
+    //       ]);
+
+    //       $participante = new Participante();
+    //       $participante->user_id = $usuario->id;
+    //       $participante->trabalho_id = $trabalho->id;
+    //       $participante->funcao_participante_id = $request->funcaoParticipante[$key];
+    //       $participante->save();
+
+    //     }else{
+    //       $participante = new Participante();
+    //       $participante->user_id = $userParticipante->id;
+    //       $participante->trabalho_id = $trabalho->id;
+    //       $participante->funcao_participante_id = $request->funcaoParticipante[$key];
+    //       $participante->save();
+
+    //       $participante->trabalhos()->save($trabalho);
+
+    //       $subject = "Participante de Projeto";
+    //       $email = $value;
+    //       Mail::to($email)
+    //             ->send(new SubmissaoTrabalho($userParticipante, $subject, $evento, $trabalho));
+    //     }
+
+    //     $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/';
+    //     $nome =  $request->nomePlanoTrabalho[$key] .".pdf";
+    //     $file = $request->anexoPlanoTrabalho[$key];
+    //     Storage::putFileAs($path, $file, $nome);
+
+    //     $arquivo = new Arquivo();
+    //     $arquivo->titulo = $request->nomePlanoTrabalho[$key];
+    //     $arquivo->nome = $path . $nome;
+    //     $arquivo->trabalhoId = $trabalho->id;
+    //     $arquivo->data = $mytime;
+    //     $arquivo->participanteId = $participante->id;
+    //     $arquivo->versaoFinal = true;
+    //     $arquivo->save();
+    //   }
 
-                  $arquivo = new Arquivo();
-                  $arquivo->titulo = $request->nomePlanoTrabalho[$key];
-                  $arquivo->nome = $path . $nome;
-                  $arquivo->trabalhoId = $trabalho->id;
-                  $arquivo->data = $mytime;
-                  $arquivo->participanteId = $participante->id;
-                  $arquivo->versaoFinal = true;
-                  $arquivo->save();
-                }
-              }
-            }
-            //removendo planos de trabalho
-            if($request->nomePlanoTrabalho != null && array_key_exists($key, $request->nomePlanoTrabalho)){
-              if($request->semPlano[$key] == 'sim'){
-                $arquivo = Arquivo::where('participanteId', $participante->id)->first();
-                //se plano já existir, deletar
-                if($arquivo != null){
-                  Storage::delete($arquivo->nome);
-                  $arquivo->delete();
-                }
-              }
-            }
-          }
-        }
-      }
+    //   //atualizando os participantes que já estão no projeto e planos de trabalho se enviados
+    //   if (in_array($request->emailParticipante[$key], $emailParticipantes, false)) {
+    //     $userParticipante = User::where('email', $value)->first();
+    //     if($userParticipante != null){
+
+    //       $user = User::where('email', $request->emailParticipante[$key])->first();
+    //       $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first();
+
+    //       $user->name = $request->nomeParticipante[$key];
+    //       $user->update();
+
+    //       $participante->funcao_participante_id = $request->funcaoParticipante[$key];
+    //       $participante->update();
+
+    //       //atualizando planos de trabalho
+    //       if ($request->anexoPlanoTrabalho != null && array_key_exists($key, $request->anexoPlanoTrabalho)) {
+    //         if (!(is_null($request->anexoPlanoTrabalho[$key]))) {
+    //           $arquivo = Arquivo::where('participanteId', $participante->id)->first();
+    //           //se plano já existir, deletar
+    //           if($arquivo != null){
+    //             Storage::delete($arquivo->nome);
+    //             $arquivo->delete();
+    //           }
+
+    //           //atualizar plano
+    //           if($request->semPlano[$key] == null){
+    //             $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/';
+    //             $nome =  $request->nomePlanoTrabalho[$key] .".pdf";
+    //             $file = $request->anexoPlanoTrabalho[$key];
+    //             Storage::putFileAs($path, $file, $nome);
+
+    //             $arquivo = new Arquivo();
+    //             $arquivo->titulo = $request->nomePlanoTrabalho[$key];
+    //             $arquivo->nome = $path . $nome;
+    //             $arquivo->trabalhoId = $trabalho->id;
+    //             $arquivo->data = $mytime;
+    //             $arquivo->participanteId = $participante->id;
+    //             $arquivo->versaoFinal = true;
+    //             $arquivo->save();
+    //           }
+    //         }
+    //       }
+    //       //removendo planos de trabalho
+    //       if($request->nomePlanoTrabalho != null && array_key_exists($key, $request->nomePlanoTrabalho)){
+    //         if($request->semPlano[$key] == 'sim'){
+    //           $arquivo = Arquivo::where('participanteId', $participante->id)->first();
+    //           //se plano já existir, deletar
+    //           if($arquivo != null){
+    //             Storage::delete($arquivo->nome);
+    //             $arquivo->delete();
+    //           }
+    //         }
+    //       }
+    //     }
+    //   }
+    // }
 
-      // Atualizando possiveis usuários removidos
-      $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get();
-      $users = User::whereIn('id', $participantesUsersIds)->get();
+    // // Atualizando possiveis usuários removidos
+    // $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get();
+    // $users = User::whereIn('id', $participantesUsersIds)->get();
+
+    // foreach ($users as $user) {
+    //   if (!(in_array($user->email, $request->emailParticipante, false))) {
+    //     $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first();
+    //     $arquivo = Arquivo::where('participanteId', $participante->id)->first();
+    //     if($arquivo != null){
+    //       Storage::delete($arquivo->nome);
+    //       $arquivo->delete();
+    //     }
+    //     $participante->delete();
+    //   }
+    // }
 
-      foreach ($users as $user) {
-        if (!(in_array($user->email, $request->emailParticipante, false))) {
-          $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first();
-          $arquivo = Arquivo::where('participanteId', $participante->id)->first();
-          if($arquivo != null){
-            Storage::delete($arquivo->nome);
-            $arquivo->delete();
-          }
-          $participante->delete();
-        }
-      }
 
-      return redirect()->route('evento.visualizar',['id'=>$request->editalId]);
-    }
 
     public function destroy(Request $request)
     {
@@ -926,12 +926,168 @@ class TrabalhoController extends Controller
     //   $trabalho->participantes()->save($participante);
     // }
 
-    public function salvar(StoreTrabalho $request) {
+    public function update(UpdateTrabalho $request, $id)
+    {
+      // dd($request->participante_id);
+      // dd( $request->all()  );
+      try {    
+        if (!$request->has('rascunho') ) {
+          $request->merge([
+            'status' => 'submetido'
+          ]);
+        }else{
+          $request->merge([
+            'status' => 'rascunho'
+          ]);
+        }
+        $evento = Evento::find($request->editalId);
+        $request->merge([
+          'coordenador_id' => $evento->coordenadorComissao->id
+        ]);
+        
+        DB::beginTransaction();
+
+        $trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
+        $trabalho->update($request->except([
+                            'anexoProjeto', 'anexoDecisaoCONSU','anexoPlanilhaPontuacao',
+                            'anexoLattesCoordenador','anexoGrupoPesquisa','anexoAutorizacaoComiteEtica',
+                            'justificativaAutorizacaoEtica'
+                          ]));
+        if ($request->marcado == null) {
+          $idExcluido = $trabalho->participantes->pluck('id');
+          
+        }else{
+          $idExcluido = [];
+        }
+        // dd($idExcluido);
+        // dd(array_search( 2, $request->marcado));
+        foreach ($request->participante_id as $key => $value) {
+          // $value = intval($value);
+          if($request->marcado != null && array_search( $key, $request->marcado) === false){
+            if($value !== null)
+              array_push($idExcluido, $value);
+          }
+        }                  
+        // dd($idExcluido);
+        foreach ($idExcluido as $key => $value) {
+          $trabalho->participantes()->find($value)->delete();
+        }
+        $trabalho->refresh();
+        if($request->has('marcado')){
+          foreach ($request->marcado as $key => $part) {
+            $part = intval($part);
+            
+            $passwordTemporario = Str::random(8);
+            $data['name'] = $request->name[$part];
+            $data['email'] = $request->email[$part];
+            $data['password'] = bcrypt($passwordTemporario);
+            $data['data_de_nascimento'] = $request->data_de_nascimento[$part];
+            $data['cpf'] = $request->cpf[$part];
+            $data['tipo'] = 'participante';
+            $data['funcao_participante_id'] = 4;
+            $data['rg'] = $request->rg[$part];
+            $data['celular'] = $request->celular[$part];
+            $data['cep'] = $request->cep[$part];
+            $data['uf'] = $request->uf[$part];
+            $data['cidade'] = $request->cidade[$part];
+            $data['rua'] = $request->rua[$part];
+            $data['numero'] = $request->numero[$part];
+            $data['bairro'] = $request->bairro[$part];
+            $data['complemento'] = $request->complemento[$part];
+            $data['instituicao'] = $request->instituicao[$part];
+            $data['total_periodos'] = $request->total_periodos[$part];
+            $data['curso'] = $request->curso[$part];
+            $data['turno'] = $request->turno[$part];
+            $data['periodo_atual'] = $request->periodo_atual[$part];
+            $data['ordem_prioridade'] = $request->ordem_prioridade[$part];
+            $data['media_do_curso'] = $request->media_do_curso[$part];
+            $data['nomePlanoTrabalho'] = $request->nomePlanoTrabalho[$part];
 
-      try {
+            $participante = Participante::find($request->participante_id[$part]);
 
-        
-        
+            if (!$participante){
+              $data['usuarioTemp'] = true;
+              $user = User::updateOrCreate(
+                ['email' => $data['email']], 
+                $data
+              );
+              $endereco = Endereco::create($data);
+              $endereco->user()->save($user);
+              $participante = Participante::create($data);
+              $user->participantes()->save($participante);
+              $trabalho->participantes()->save($participante);
+
+            }else{
+              $user = $participante->user;
+              $user->update($data);
+              $endereco =  $user->endereco;
+              $endereco->update($data);
+              $participante = $user->participantes->where('trabalho_id', $trabalho->id)->first();
+              if (!$participante){
+                $participante = Participante::create($data);
+                $user->participantes()->save($participante);
+                $trabalho->participantes()->save($participante);
+              }else{
+                $participante->update($data);
+              }
+              
+            }
+    
+            
+    
+            if ( $request->has('anexoPlanoTrabalho') && array_key_exists($part,$request->anexoPlanoTrabalho) ) {
+              if(Arquivo::where('participanteId', $participante->id)->count()){
+                  $arquivo = Arquivo::where('participanteId', $participante->id)->first();
+                  $path = 'trabalhos/' . $evento->id . '/' . $trabalho->id .'/';
+                  $nome =  $data['nomePlanoTrabalho'] .".pdf";
+                  $file = $request->anexoPlanoTrabalho[$part] ;
+                  Storage::putFileAs($path, $file, $nome);
+                  $arquivo->update([
+                    'titulo' => $nome,
+                    'nome' => $path . $nome,
+                    'data' => now() ,
+                  ]);
+              }else{
+                $path = 'trabalhos/' . $evento->id . '/' . $trabalho->id .'/';
+                $nome =  $data['nomePlanoTrabalho'] .".pdf";
+                $file = $request->anexoPlanoTrabalho[$part] ;
+                Storage::putFileAs($path, $file, $nome);
+                $arquivo = new Arquivo();
+                $arquivo->titulo = $data['nomePlanoTrabalho'];
+                $arquivo->nome = $path . $nome;
+                $arquivo->trabalhoId = $trabalho->id;
+                $arquivo->data = now();
+                $arquivo->participanteId = $participante->id;
+                $arquivo->versaoFinal = true;
+                $arquivo->save();
+
+              }
+              
+            }
+    
+          }
+          
+        }
+
+  
+        $pasta = 'trabalhos/' . $evento->id . '/' . $trabalho->id;
+        $trabalho = $this->armazenarAnexosFinais($request, $pasta, $trabalho, $evento);
+        $trabalho->save();
+
+        DB::commit();
+
+        return redirect(route('proponente.projetos'))->with(['mensagem' => 'Proposta atualizada!']);
+      } catch (\Throwable $th) {
+        DB::rollback();
+        return redirect(route('proponente.projetos'))->with(['mensagem' => $th->getMessage()]);
+      }
+
+    }
+
+
+    public function salvar(StoreTrabalho $request) {
+
+      try {    
         if (!$request->has('rascunho') ) {
           $request->merge([
             'status' => 'submetido'
@@ -969,6 +1125,7 @@ class TrabalhoController extends Controller
             $data['cidade'] = $request->cidade[$part];
             $data['rua'] = $request->rua[$part];
             $data['numero'] = $request->numero[$part];
+            $data['bairro'] = $request->bairro[$part];
             $data['complemento'] = $request->complemento[$part];
             $data['instituicao'] = $request->instituicao[$part];
             $data['total_periodos'] = $request->total_periodos[$part];
diff --git a/app/Http/Requests/StoreTrabalho.php b/app/Http/Requests/StoreTrabalho.php
index 544dd0d..1d0dcd3 100644
--- a/app/Http/Requests/StoreTrabalho.php
+++ b/app/Http/Requests/StoreTrabalho.php
@@ -33,7 +33,6 @@ class StoreTrabalho extends FormRequest
             'titulo'                => ['required', 'string'],
             'grande_area_id'              => ['required', 'string'],
             'area_id'                    => ['required', 'string'],
-            'sub_area_id'                 => ['required', 'string'],
             'linkLattesEstudante'         => ['required', 'string'],
             'pontuacaoPlanilha'       => ['required', 'string'],
             'linkGrupoPesquisa'               => ['required', 'string'],
@@ -80,7 +79,6 @@ class StoreTrabalho extends FormRequest
             }
 
         }
-        // dd($rules);
 
         if ($this->has('rascunho')) {
             return [
diff --git a/app/Http/Requests/UpdateTrabalho.php b/app/Http/Requests/UpdateTrabalho.php
index 1cbb2b6..b9f5ed5 100644
--- a/app/Http/Requests/UpdateTrabalho.php
+++ b/app/Http/Requests/UpdateTrabalho.php
@@ -2,7 +2,10 @@
 
 namespace App\Http\Requests;
 
+use App\Trabalho;
 use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Validation\Rule;
 
 class UpdateTrabalho extends FormRequest
 {
@@ -13,7 +16,7 @@ class UpdateTrabalho extends FormRequest
      */
     public function authorize()
     {
-        return false;
+        return true;
     }
 
     /**
@@ -23,8 +26,69 @@ class UpdateTrabalho extends FormRequest
      */
     public function rules()
     {
-        return [
-            //
+        $projeto = Trabalho::find($this->id);
+        
+        $rules = [
+            'editalId'                => ['required', 'string'],
+            'marcado.*'                => ['required'],
+            'titulo'                => ['required', 'string'],
+            'grande_area_id'              => ['required', 'string'],
+            'area_id'                    => ['required', 'string'],
+            'linkLattesEstudante'         => ['required', 'string'],
+            'pontuacaoPlanilha'       => ['required', 'string'],
+            'linkGrupoPesquisa'               => ['required', 'string'],
+            'anexoProjeto'     => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoProjeto == null)], 'mimes:pdf'],
+            'anexoDecisaoCONSU'     => ['mimes:pdf'],
+            'anexoPlanilhaPontuacao'     => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoPlanilhaPontuacao == null)]],
+            'anexoLattesCoordenador'     => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoLattesCoordenador == null)], 'mimes:pdf'],
+            'anexoGrupoPesquisa'     => [[Rule::requiredIf(!$this->has('rascunho') && $projeto->anexoGrupoPesquisa == null)], 'mimes:pdf'],
+            'anexoAutorizacaoComiteEtica'     => [
+                Rule::requiredIf((!$this->has('rascunho') && $projeto->anexoAutorizacaoComiteEtica == null) )
+            ],
+            'justificativaAutorizacaoEtica'   => [
+                Rule::requiredIf((!$this->has('rascunho') && $projeto->anexoAutorizacaoComiteEtica == null))
+            ],
+            
         ];
+        if($this->has('marcado')){
+            foreach ($this->get('marcado') as $key => $value) {
+                if( intval($value)  == $key){
+                    //user
+                    $rules['name.'.$value] = ['required', 'string'];
+                    $rules['email.'.$value] = ['required', 'string'];
+                    $rules['instituicao.'.$value] = ['required', 'string'];
+                    $rules['cpf.'.$value] = ['required', 'string'];
+                    $rules['celular.'.$value] = ['required', 'string'];
+                    //endereco
+                    $rules['rua.'.$value] = ['required', 'string'];
+                    $rules['numero.'.$value] = ['required', 'string'];
+                    $rules['bairro.'.$value] = ['required', 'string'];
+                    $rules['cidade.'.$value] = ['required', 'string'];
+                    $rules['uf.'.$value] = ['required', 'string'];
+                    $rules['cep.'.$value] = ['required', 'string'];
+                    $rules['complemento.'.$value] = ['required', 'string'];
+                    //participante
+                    $rules['rg.'.$value] = ['required', 'string'];
+                    $rules['data_de_nascimento.'.$value] = ['required', 'string'];
+                    $rules['curso.'.$value] = ['required', 'string'];
+                    $rules['turno.'.$value] = ['required', 'string'];
+                    $rules['ordem_prioridade.'.$value] = ['required', 'string'];
+                    $rules['periodo_atual.'.$value] = ['required', 'string'];
+                    $rules['total_periodos.'.$value] = ['required', 'string'];
+                    $rules['media_do_curso.'.$value] = ['required', 'string'];
+                    $rules['nomePlanoTrabalho.'.$value] = ['required', 'string'];
+    
+                }
+            }
+
+        }
+        // dd($this->all());
+        if ($this->has('rascunho')) {
+            return [
+                
+            ];
+        }else{
+            return $rules;
+        }
     }
 }
diff --git a/database/migrations/2021_07_01_020325_alter_table_arquivos.php b/database/migrations/2021_07_01_020325_alter_table_arquivos.php
new file mode 100644
index 0000000..278115d
--- /dev/null
+++ b/database/migrations/2021_07_01_020325_alter_table_arquivos.php
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AlterTableArquivos extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('arquivos', function (Blueprint $table) {
+            $table->string('nome')->nullable()->change();
+            $table->string('titulo')->nullable()->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('arquivos', function (Blueprint $table) {
+            //
+        });
+    }
+}
diff --git a/resources/views/componentes/input.blade.php b/resources/views/componentes/input.blade.php
index f17e3f2..57788b3 100644
--- a/resources/views/componentes/input.blade.php
+++ b/resources/views/componentes/input.blade.php
@@ -1,10 +1,11 @@
 @php
   $class = $class ?? " ";
-  $obrigatorio = $obrigatorio ?? " ";
+  // $obrigatorio = $obrigatorio ?? " ";
 @endphp
 <div class="form-group">
-  <label class=" control-label {{ $class }}" for="firstname">{{ $label }} @if($obrigatorio)  <span style="color: red; font-weight:bold">*</span> @endif</label>
+  <label class=" control-label {{ $class }}" for="firstname">{{  $label  }} <span style="color: red; font-weight:bold">*</span></label>
+  {{ $slot }}
   <div class="">
-    {{ $slot }}
+    
   </div>
 </div>
diff --git a/resources/views/evento/formulario/anexos.blade.php b/resources/views/evento/formulario/anexos.blade.php
index 6ad5fb0..ec31528 100644
--- a/resources/views/evento/formulario/anexos.blade.php
+++ b/resources/views/evento/formulario/anexos.blade.php
@@ -42,14 +42,13 @@
             @endcomponent
           </div>
           <div class="form-group col-md-6">
-            @component('componentes.input', ['label' => 'Decisão do CONSU (.pdf)'])
-              <input type="file" class="input-group-text" name="anexoDecisaoCONSU" placeholder="anexoDecisaoCONSU" accept=".pdf" />
+            <label class=" control-label" for="firstname">Decisão do CONSU (.pdf)</label>
+              <input type="file" class="input-group-text" name="anexoDecisaoCONSU"  accept=".pdf" />
               @error('anexoDecisaoCONSU')
                 <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                   <strong>{{ $message }}</strong>
                 </span>
-              @enderror
-            @endcomponent
+              @enderror 
           </div>
           
           <div class="form-group col-md-6" style="margin-top: 10px">
diff --git a/resources/views/evento/formulario/participantes.blade.php b/resources/views/evento/formulario/participantes.blade.php
index 7352dc7..1f3d222 100644
--- a/resources/views/evento/formulario/participantes.blade.php
+++ b/resources/views/evento/formulario/participantes.blade.php
@@ -70,13 +70,8 @@
                           </div>                              
                           <div class="col-6">
                                 @component('componentes.input', ['label' => 'CPF'])
-                                  <input type="text" class="form-control cpf" value="{{old('cpf')[$i] ?? "" }}" name="cpf[{{$i}}]" placeholder="CPF"  onchange="checarCPFdoCampo(this)" onkeyup="mascaraCPF(this)"/>
-                                  <span id="cpf-invalido-1" class="invalid-feedback cpf-invalido" role="alert" style="overflow: visible; display:none">
-                                    <span style="font-style: italic;">CPF inválido.</span>
-                                  </span>
-                                  <span id="cpf-valido-1" class="valid-feedback" role="alert" style="overflow: visible; display:none">
-                                    <span style="font-style: italic;">CPF válido.</span>
-                                  </span>
+                                  <input type="text" class="form-control cpf" value="{{old('cpf')[$i] ?? "" }}" name="cpf[{{$i}}]" placeholder="CPF"  />
+                                  
                                   @error('cpf.'.$i)
                                     <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                       <strong>{{ $message }}</strong>
@@ -107,7 +102,7 @@
                           <div class="col-md-12"><h5>Endereço</h5></div>                              
                           <div class="col-6">
                                 @component('componentes.input', ['label' => 'CEP'])
-                                  <input type="number" class="form-control" value="{{old('cep')[$i] ?? "" }}" name="cep[{{$i}}]"  placeholder="CEP" />
+                                  <input type="text" class="form-control" value="{{old('cep')[$i] ?? "" }}" name="cep[{{$i}}]"  placeholder="CEP" />
                                   @error('cep.'.$i)
                                     <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                       <strong>{{ $message }}</strong>
diff --git a/resources/views/projeto/editaFormulario/anexos.blade.php b/resources/views/projeto/editaFormulario/anexos.blade.php
index 367b3d9..9cb5a32 100644
--- a/resources/views/projeto/editaFormulario/anexos.blade.php
+++ b/resources/views/projeto/editaFormulario/anexos.blade.php
@@ -13,12 +13,23 @@
             <div class="row justify-content-center">
               <div class="col-12">
                 @component('componentes.input', ['label' => 'Projeto (.pdf)'])
-                  <input type="file" class="input-group-text" name="anexoProjeto" placeholder="nomeProjeto" accept="application/pdf" />
+                  <input type="file" class="input-group-text" name="anexoProjeto" accept="application/pdf" />
+                  @error('anexoProjeto')
+                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                      <strong>{{ $message }}</strong>
+                    </span>
+                  @enderror
                 @endcomponent
               </div>
-              <div class="col-3 ">
-                <a href="{{ route('baixar.anexo.projeto', ['id' => $projeto->id])}}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoProjeto)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexo.projeto', ['id' => $projeto->id])}}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           {{-- Anexo do currículo --}}
@@ -26,12 +37,23 @@
             <div class="row justify-content-center">
               <div class="col-12">
                 @component('componentes.input', ['label' => 'Currículo Lattes do Proponente (.pdf)'])
-                  <input type="file" class="input-group-text" name="anexoLattesCoordenador" placeholder="anexoPlanoTrabalho" accept=".pdf" />
+                  <input type="file" class="input-group-text" name="anexoLattesCoordenador" accept=".pdf" />
+                  @error('anexoLattesCoordenador')
+                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                      <strong>{{ $message }}</strong>
+                    </span>
+                  @enderror
                 @endcomponent
               </div>
-              <div class="col-3 ">
-                <a href="{{ route('baixar.anexo.lattes', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoLattesCoordenador)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexo.lattes', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           {{-- Anexo da Planilha de Pontuação --}}
@@ -39,12 +61,24 @@
             <div class="row justify-content-center">
               <div class="col-12">
                 @component('componentes.input', ['label' => 'Planilha de Pontuação (.xlsx,.xls,.ods)'])
-                  <input type="file" class="input-group-text" name="anexoPlanilha" placeholder="anexoPlanoTrabalho" accept=".xlsx, .xls, .ods" />
+                  <input type="file" class="input-group-text" name="anexoPlanilhaPontuacao" accept=".xlsx, .xls, .ods" />
+                  @error('anexoPlanilhaPontuacao')
+                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                      <strong>{{ $message }}</strong>
+                    </span>
+                  @enderror
                 @endcomponent
               </div>
-              <div class="col-3 ">
-                <a href="{{ route('baixar.anexo.planilha', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoPlanilhaPontuacao)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexo.planilha', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
+              
             </div>
           </div>
           
@@ -52,13 +86,28 @@
           <div class="form-group col-md-6" style="margin-top: 10px">
             <div class="row justify-content-center">
               <div class="col-12">
-                @component('componentes.input', ['label' => 'Decisão do CONSU (.pdf)'])
-                  <input type="file" class="input-group-text" name="anexoConsuPreenchido" placeholder="anexoConsuPreenchido" accept=".pdf" />
-                @endcomponent
-              </div>
-              <div class="col-3 ">
-                <a href="{{ route('baixar.anexo.consu', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                <div class="form-group">
+                  <label class=" control-label" for="firstname">Decisão do CONSU (.pdf)</label>
+                  
+                  <input type="file" class="input-group-text" name="anexoDecisaoCONSU"  accept=".pdf" />
+                  @error('anexoDecisaoCONSU')
+                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                      <strong>{{ $message }}</strong>
+                    </span>
+                  @enderror
+                </div>
+                
               </div>
+              @if($projeto->anexoDecisaoCONSU)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexo.consu', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
+              
             </div>
           </div>
           
@@ -68,20 +117,32 @@
               <div class="col-12">
                 @component('componentes.input', ['label' => 'Grupo de Pesquisa (.pdf)'])
                   <input type="file" class="input-group-text" name="anexoGrupoPesquisa" placeholder="Anexo do Grupo de Pesquisa" accept="application/pdf" />
+                  @error('anexoGrupoPesquisa')
+                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                      <strong>{{ $message }}</strong>
+                    </span>
+                  @enderror
                 @endcomponent
               </div>
-              <div class="col-3 ">
-                <a href="{{ route('baixar.anexoGrupoPesquisa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoGrupoPesquisa)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexoGrupoPesquisa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
+              
             </div>
           </div>
         
 
           <div class="form-group col-md-6">
             <label for="botao" class="col-form-label @error('botao') is-invalid @enderror" data-toggle="tooltip" data-placement="bottom" title="Se possuir, coloque todas em único arquivo pdf." style="margin-right: 15px;">{{ __('Possui autorizações especiais?') }} <span style="color: red; font-weight:bold">*</span></label>
-            <input type="radio" checked id="radioSim" onchange="displayAutorizacoesEspeciais('sim')">
+            <input type="radio" checked id="radioSim" name="sim" onchange="displayAutorizacoesEspeciais('sim')">
             <label for="radioSim" style="margin-right: 5px">Sim</label>
-            <input type="radio" id="radioNao" onchange="displayAutorizacoesEspeciais('nao')">
+            <input type="radio" id="radioNao" name="nao" onchange="displayAutorizacoesEspeciais('nao')">
             <label for="radioNao" style="margin-right: 5px">Não</label><br>
             <span id="idAvisoAutorizacaoEspecial" class="invalid-feedback" role="alert" style="overflow: visible; display:none">
               <strong>Selecione a autorização e envie o arquivo!</strong>
@@ -89,20 +150,52 @@
             
             <div class="form-group" id="displaySim" style="display: block; margin-top:-1rem">
               @component('componentes.input', ['label' => 'Sim, declaro que necessito de autorizações especiais (.pdf)'])
-                <input type="file" class="input-group-text" name="anexoComiteEtica" placeholder="anexoComiteEtica" accept=".pdf" />
+                <input type="file" class="input-group-text" name="anexoAutorizacaoComiteEtica" accept=".pdf" />
+                <div class="row justify-content-center">
+                  @if($projeto->justificativaAutorizacaoEtica || $projeto->anexoAutorizacaoComiteEtica ) 
+                  <div class="row justify-content-center">
+                    <div class="col-3 mt-2">
+                      <a href="{{ route('baixar.anexo.comite', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                    </div>
+                  </div>
+                  @else
+                    <div class="col-3 text-danger">
+                      <p><i class="fas fa-times-circle fa-2x"></i></p>
+                    </div>
+                  @endif
+                  
+                </div>
+                @error('anexoAutorizacaoComiteEtica')
+                  <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                    <strong>{{ $message }}</strong>
+                  </span>
+                @enderror
               @endcomponent
             </div>
 
             <div class="form-group" id="displayNao" style="display: none; margin-top:-1rem">
               @component('componentes.input', ['label' => 'Declaração de que não necessito de autorização especiais (.pdf)'])
-                <input type="file" class="input-group-text" name="inputJustificativa" placeholder="inputJustificativa" accept=".pdf" />
-              @endcomponent
-            </div>
-            <div class="row justify-content-center">
-              <div class="col-3 ">
-                <a href="{{ route('baixar.anexo.justificativa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+                <input type="file" class="input-group-text" name="justificativaAutorizacaoEtica"  accept=".pdf" />
+                  @if($projeto->justificativaAutorizacaoEtica || $projeto->anexoAutorizacaoComiteEtica ) 
+                  <div class="row justify-content-center">
+                    <div class="col-3 mt-2">
+                      <a href="{{ route('baixar.anexo.justificativa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                    </div>
+                  </div>
+                  @else
+                    <div class="col-3 text-danger">
+                      <p><i class="fas fa-times-circle fa-2x"></i></p>
+                    </div>
+                  @endif
+                
+                  @error('justificativaAutorizacaoEtica')
+                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                      <strong>{{ $message }}</strong>
+                    </span>
+                  @enderror
+                @endcomponent
             </div>
+            
            
           </div>
           
diff --git a/resources/views/projeto/editaFormulario/finalizar.blade.php b/resources/views/projeto/editaFormulario/finalizar.blade.php
index fcec615..09bb8e7 100644
--- a/resources/views/projeto/editaFormulario/finalizar.blade.php
+++ b/resources/views/projeto/editaFormulario/finalizar.blade.php
@@ -12,7 +12,8 @@
       <div class=" d-flex justify-content-between align-items-center" style="margin-top: 15px; margin-bottom:18px">
         <h6 style="font-family:Arial, Helvetica, sans-serif; margin-right:15px"><span style="color: red; font-weight:bold">*</span> Campos obrigatórios</h6>
         <button id="submeterFormProposta" type="submit" style="display: none;"></button>
-        <button type="button" class="btn btn-success" id="idButtonSubmitProjeto" onclick="submeterProposta()">{{ __('Atualizar Projeto') }}</button>
+        <button type="submit" class="btn btn-primary " id="idButtonSubmitRascunho" >{{ __('Atualizar rascunho') }}</button>
+        <button type="submit" class="btn btn-success" id="idButtonSubmitProjeto" >{{ __('Atualizar Proposta') }}</button>
       </div>
     </div>
   </div>
diff --git a/resources/views/projeto/editaFormulario/participantes.blade.php b/resources/views/projeto/editaFormulario/participantes.blade.php
index 43608d0..4c46587 100644
--- a/resources/views/projeto/editaFormulario/participantes.blade.php
+++ b/resources/views/projeto/editaFormulario/participantes.blade.php
@@ -18,188 +18,598 @@
       <li id="item">
         <div style="margin-bottom:15px">
           <div id="participante" >
-            @foreach ($participantes as $key => $p)
-            <div class="form-row mt-2">
-                <div class="col-md-11">
-                  <a class="btn btn-light" data-toggle="collapse" id="idCollapseParticipante" href="#collapseParticipante{{ $p->id }}" role="button" aria-expanded="false" aria-controls="collapseParticipante" style="width: 100%; text-align:left">
-                    <div class="d-flex justify-content-between align-items-center">
-                      <h4 id="tituloParticipante" style="color: #01487E; font-size:17px; margin-top:5px">Discente<span id="pontos" style="display: none;">:</span> <span style="display: none;" id="display"></span>  </h4>
+            @for($i = 0; $i < $edital->numParticipantes; $i++)
+              @php
+                $p = null;
+                if ($projeto->participantes->keys()->contains($i)) {
+                  $p = $projeto->participantes[$i];
+                }
+                
+              @endphp
+
+                @if($p)
+                  <div class="form-row mb-1">
+                    <div class="col-md-11">
+                      <a class="btn btn-light" data-toggle="collapse" id="idCollapseParticipante" href="#collapseParticipante{{$i}}" role="button" aria-expanded="false" aria-controls="collapseParticipante" style="width: 100%; text-align:left">
+                        <div class="d-flex justify-content-between align-items-center">
+                          <h4 id="tituloParticipante" style="color: #01487E; font-size:17px; margin-top:5px">Discente<span id="pontos" style="display: none;">:</span> <span style="display: none;" id="display"></span>  </h4>
+                        </div>
+                      </a>
+                    </div>
+                    <div class="col-1" style="margin-top:9.3px">
+                      {{-- <button type="button" class="btn btn-danger shadow-sm" id="buttonRemover" onclick="removerPart(this)" >X</button> --}}
+                      <input type="checkbox" aria-label="Checkbox for following text input" @if(old('name')[$i] ?? $p) checked @endif name="marcado[]" value="{{ $i }}">
                     </div>
-                  </a>
-                </div>
-                <div class="col-1" style="margin-top:4.3px">
-                  <button type="button" class="btn btn-danger shadow-sm" id="buttonRemover" onclick="removerPart(this)" >X</button>
-                </div>
-                <div class="col-md-12">
-                  <div class="collapse" id="collapseParticipante{{ $p->id }}">
-                    <div class="container">
-                        <div class="row">
-                          <input type="hidden" name="participante_id[]" value="{{ $p->id }}">
-                          <input type="hidden"  name="funcaoParticipante[]" value="4">
-                          <div class="col-md-12 mt-3"><h5>Dados do discente</h5></div>
-                          <div class="col-6">
+                    <div class="col-md-12">
+                      <div class="collapse" id="collapseParticipante{{$i}}">
+                        <div class="container">
+                            <div class="row">
+                              <input type="hidden" name="participante_id[]" value="{{ $p->id ?? "" }}">
+                              <input type="hidden"  name="funcaoParticipante[]" value="4">
+                              <div class="col-md-12 mt-3"><h5>Dados do discente</h5></div>
+                              <div class="col-6">
                                 @component('componentes.input', ['label' => 'Nome completo'])
-                                  <input type="text" class="form-control " value="{{ $p->user->name }}"   name="nomeParticipante[]" placeholder="Nome Completo" required />
-                                @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'E-mail'])
-                                  <input type="email" class="form-control" value="{{ $p->user->email }}" name="emailParticipante[]" placeholder="E-mail" required/>
-                                @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Data de nascimento'])
-                                  <input type="date" class="form-control" value="{{ $p->data_de_nascimento }}" name="data_de_nascimento[]" placeholder="Data de nascimento" required/>
-                                @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'CPF'])
-                                  <input type="text" class="form-control cpf" value="{{ $p->user->cpf }}"  name="cpf[]" placeholder="CPF" required />
-                                  <span id="cpf-invalido-1" class="invalid-feedback cpf-invalido" role="alert" style="overflow: visible; display:none">
-                                    <span style="font-style: italic;">CPF inválido.</span>
-                                  </span>
-                                  <span id="cpf-valido-1" class="valid-feedback" role="alert" style="overflow: visible; display:none">
-                                    <span style="font-style: italic;">CPF válido.</span>
-                                  </span>
-                                @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'RG'])
-                                  <input type="number" class="form-control" value="{{ $p->rg }}" min="1" maxlength="12" name="rg[]" placeholder="RG" required/>
-                                @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Celular'])
-                                  <input type="tel" class="form-control celular" value="{{ $p->user->celular }}" name="celular[]" placeholder="Celular" required/>
-                                @endcomponent
-                          </div>
-                          <div class="col-md-12"><h5>Endereço</h5></div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'CEP'])
-                                  <input type="number" class="form-control" value="{{ $p->user->endereco->cep }}" name="cep[]" placeholder="CEP" required/>
+                                  <input type="text" class="form-control " value="{{old('name')[$i] ?? $p->user->name }}"  name="name[{{$i}}]" placeholder="Nome Completo"  />
+                                  
+                                  @error("name.".$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>           
-                                            
-                          <div class="col-6">
-                            @component('componentes.select', ['label' => 'Estado'])
-                              <select name="uf[]" id="estado" class="form-control"   style="visibility: visible" required>
-                                <option value="" disabled selected>-- Selecione uma opção --</option>
-                                @foreach ($estados as $sigla => $nome)
-                                  <option @if( $p->user->endereco->uf == $sigla ) selected @endif value="{{ $sigla }}">{{ $nome }}</option>
-                                @endforeach
-                              </select>
-                            @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Cidade'])
-                                  <input type="text" class="form-control" value="{{ $p->user->endereco->cidade }}" name="cidade[]" placeholder="Cidade" required/>
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'E-mail'])
+                                      <input type="email" class="form-control" value="{{old('email')[$i] ?? $p->user->email }}" name="email[{{$i}}]" placeholder="E-mail" />
+                                      @error('email.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Data de nascimento'])
+                                      <input type="date" class="form-control"  value="{{old('data_de_nascimento')[$i] ?? $p->data_de_nascimento }}" name="data_de_nascimento[{{$i}}]" placeholder="Data de nascimento" />
+                                      @error('data_de_nascimento.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'CPF'])
+                                      <input type="text" class="form-control cpf" value="{{old('cpf')[$i] ?? $p->user->cpf }}" name="cpf[{{$i}}]" placeholder="CPF" />
+                                      
+                                      @error('cpf.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'RG'])
+                                      <input type="number" class="form-control"  min="1" maxlength="12" value="{{old('rg')[$i] ?? $p->rg  }}" name="rg[{{$i}}]"  placeholder="RG" />
+                                      @error('rg.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Celular'])
+                                      <input type="tel" class="form-control celular"  value="{{old('celular')[$i] ?? $p->user->celular }}" name="celular[{{$i}}]"  placeholder="Celular" />
+                                      @error('celular.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>
+                              <div class="col-md-12"><h5>Endereço</h5></div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'CEP'])
+                                      <input type="text" class="form-control" value="{{old('cep')[$i] ?? $p->user->endereco->cep }}" name="cep[{{$i}}]"  placeholder="CEP" />
+                                      @error('cep.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>           
+                                                  
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Estado'])
+                                  <select name="uf[{{$i}}]"  id="estado" class="form-control"   style="visibility: visible" >
+                                    <option value=""  selected>-- Selecione uma opção --</option>
+                                    @foreach ($estados as $sigla => $nome)
+                                      <option @if(old('uf')[$i] ?? $p->user->endereco->uf == $sigla ) selected @endif value="{{ $sigla }}">{{ $nome }}</option>
+                                    @endforeach
+                                  </select>
+                                  @error('uf.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Bairro'])
-                                  <input type="text" class="form-control" value="{{ $p->user->endereco->bairro }}" name="bairro[]" placeholder="Bairro" required/>
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Cidade'])
+                                      <input type="text" class="form-control" value="{{old('cidade')[$i] ?? $p->user->endereco->cidade }}" name="cidade[{{$i}}]"  placeholder="Cidade" />
+                                      @error('cidade.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Bairro'])
+                                      <input type="text" class="form-control" value="{{old('bairro')[$i] ?? $p->user->endereco->bairro }}" name="bairro[{{$i}}]"  placeholder="Bairro" />
+                                      @error('bairro.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Rua'])
+                                      <input type="text" class="form-control" value="{{old('rua')[$i] ?? $p->user->endereco->rua }}" name="rua[{{$i}}]" placeholder="Rua" />
+                                      @error('rua.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Número'])
+                                      <input type="text" class="form-control" value="{{old('numero')[$i] ??  $p->user->endereco->numero }}" name="numero[{{$i}}]"  placeholder="Número" />
+                                      @error('numero.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-12">
+                                    @component('componentes.input', ['label' => 'Complemento',])
+                                      <input type="text" class="form-control" value="{{old('complemento')[$i] ?? $p->user->endereco->complemento }}" name="complemento[{{$i}}]"    placeholder="Complemento" />
+                                    @error('complemento.'.$i)
+                                      <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                        <strong>{{ $message }}</strong>
+                                      </span>
+                                    @enderror
+                                    @endcomponent
+                              </div>
+                              <div class="col-md-12"><h5>Dados do curso</h5></div>                               
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Universidade'])
+                                      <input type="text" class="form-control" value="{{old('instituicao')[$i] ?? $p->user->instituicao }}" name="instituicao[{{$i}}]"  placeholder="Universidade" />
+                                      @error('instituicao.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Curso'])
+                                      <input type="text" class="form-control" value="{{old('curso')[$i] ?? $p->curso }}" name="curso[{{$i}}]"  placeholder="Curso" />
+                                      @error('curso.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Turno'])
+                                  <select  name="turno[{{$i}}]"  class="form-control" >
+                                    <option value=""  selected>-- Selecione uma opção --</option>
+                                    @foreach ($enum_turno as $key => $value)
+                                      <option @if(old('turno')[$i] ?? $p->turno == $value ) selected @endif value="{{ $value }}">{{ $value }}</option>
+                                    @endforeach
+                                  </select>
+                                  @error('turno.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Rua'])
-                                  <input type="text" class="form-control" value="{{ $p->user->endereco->rua }}" name="rua[]" placeholder="Rua" required/>
+                              </div>
+                              @php
+                                $options = array('6' => 6, '7' => 7,'8' => 8,'9' => 9,'10' => 10,'11' => 11,'12' => 12); 
+                              @endphp                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Total de períodos do curso'])
+                                  <select  name="total_periodos[{{$i}}]"   class="form-control" onchange="gerarPeriodo(this)" >
+                                    <option value=""  selected>-- Selecione uma opção --</option>
+                                    @foreach ($options as $key => $value)
+                                      <option @if(old('total_periodos')[$i]  ?? $p->total_periodos == $key ) selected @endif value="{{ $key }}">{{ $value }}</option>
+                                    @endforeach
+                                  </select>
+                                  @error('total_periodos.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Número'])
-                                  <input type="text" class="form-control" value="{{ $p->user->endereco->numero }}" name="numero[]" placeholder="Número" required/>
+                              </div>                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Período atual'])
+                                  <select name="periodo_atual[]"  class="form-control"  >
+                                    <option selected value="{{ old('periodo_atual')[$i]  ?? $p->periodo_atual }}">{{ old('periodo_atual')[$i]  ?? $p->periodo_atual }}</option>
+                                  </select>
+                                  @error('periodo_atual.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-12">
-                                @component('componentes.input', ['label' => 'Complemento', 'obrigatorio' => ''])
-                                  <input type="text" class="form-control" value="{{ $p->user->endereco->complemento }}" name="complemento[]"  pattern="[A-Za-z]+" placeholder="Complemento"/>
+                              </div>                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Ordem de prioridade'])
+                                  <select name="ordem_prioridade[]"  class="form-control" >
+                                    <option value=""  selected>-- ORDEM --</option>
+                                    @for($j = 1; $j <= 3; $j++)
+                                      <option @if(old('ordem_prioridade')[$i]  ?? $p->ordem_prioridade == $j ) selected @endif value="{{ $j }}">{{ $j }}</option>  
+                                    @endfor
+    
+                                  </select>
+                                  @error('ordem_prioridade.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>
-                          <div class="col-md-12"><h5>Dados do curso</h5></div>                               
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Universidade'])
-                                  <input type="text" class="form-control" value="{{ $p->user->instituicao }}" name="universidade[]" placeholder="Universidade" required/>
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Coeficiente de rendimento'])
+                                    <input type="number" class="form-control media" value="{{old('media_do_curso')[$i] ?? $p->media_do_curso }}" name="media_do_curso[{{$i}}]"  min="0" max="10" step="0.01"  >
+                                    @error('media_do_curso.'.$i)
+                                      <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                        <strong>{{ $message }}</strong>
+                                      </span>
+                                    @enderror
+                                    @endcomponent
+                              </div>
+                              <div class="col-md-12"><h5>Plano de trabalho</h5></div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Título'])
+                                      <input type="text" class="form-control" value="{{$p->planoTrabalho ? $p->planoTrabalho->titulo : "" }}" name="nomePlanoTrabalho[{{$i}}]"  placeholder="Digite o título do plano de trabalho" >
+                                      @error('nomePlanoTrabalho.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Anexo(.pdf)'])
+                                      <input type="file" class="input-group-text" value="{{old('anexoPlanoTrabalho')[$i] ?? "" }}" name="anexoPlanoTrabalho[{{$i}}]"  accept=".pdf" placeholder="Anexo do Plano de Trabalho" />
+                                      @error('anexoPlanoTrabalho.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                      @error('anexoPlanoTrabalho')
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                                    @if($p->planoTrabalho)
+                                    <div class="row justify-content-center">
+                                      <div class="col-3 ">
+                                        <a href="{{ route('baixar.plano', ['id' => $p->planoTrabalho->id]) }}">
+                                        <i class="fas fa-file-pdf fa-2x"></i></a>
+                                      </div>
+                                    </div>
+                                      
+                                    @endif
+                              </div>                              
+                            </div>
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                @else
+                  <div class="form-row mb-1">
+                    <div class="col-md-11">
+                      <a class="btn btn-light" data-toggle="collapse" id="idCollapseParticipante" href="#collapseParticipante{{$i}}" role="button" aria-expanded="false" aria-controls="collapseParticipante" style="width: 100%; text-align:left">
+                        <div class="d-flex justify-content-between align-items-center">
+                          <h4 id="tituloParticipante" style="color: #01487E; font-size:17px; margin-top:5px">Discente<span id="pontos" style="display: none;">:</span> <span style="display: none;" id="display"></span>  </h4>
+                        </div>
+                      </a>
+                    </div>
+                    <div class="col-1" style="margin-top:9.3px">
+                      {{-- <button type="button" class="btn btn-danger shadow-sm" id="buttonRemover" onclick="removerPart(this)" >X</button> --}}
+                      <input type="checkbox" aria-label="Checkbox for following text input" @if(old('name')[$i] ?? "") checked @endif name="marcado[]" value="{{ $i }}">
+                    </div>
+                    <div class="col-md-12">
+                      <div class="collapse" id="collapseParticipante{{$i}}">
+                        <div class="container">
+                            <div class="row">
+                              <input type="hidden" name="participante_id[]" value="">
+                              <input type="hidden"  name="funcaoParticipante[]" value="4">
+                              <div class="col-md-12 mt-3"><h5>Dados do discente</h5></div>
+                              <div class="col-6">
+                                @component('componentes.input', ['label' => 'Nome completo'])
+                                  <input type="text" class="form-control " value="{{old('name')[$i] ?? "" }}"  name="name[{{$i}}]" placeholder="Nome Completo"  />
+                                  
+                                  @error("name.".$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Curso'])
-                                  <input type="text" class="form-control" value="{{ $p->curso }}" name="curso[]" placeholder="Curso" required/>
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'E-mail'])
+                                      <input type="email" class="form-control" value="{{old('email')[$i] ??  "" }}" name="email[{{$i}}]" placeholder="E-mail" />
+                                      @error('email.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Data de nascimento'])
+                                      <input type="date" class="form-control"  value="{{old('data_de_nascimento')[$i] ??  "" }}" name="data_de_nascimento[{{$i}}]" placeholder="Data de nascimento" />
+                                      @error('data_de_nascimento.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'CPF'])
+                                      <input type="text" class="form-control cpf" value="{{old('cpf')[$i] ??  "" }}" name="cpf[{{$i}}]" placeholder="CPF"  />
+                                      
+                                      @error('cpf.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'RG'])
+                                      <input type="number" class="form-control"  min="1" maxlength="12" value="{{old('rg')[$i] ??  ""  }}" name="rg[{{$i}}]"  placeholder="RG" />
+                                      @error('rg.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Celular'])
+                                      <input type="tel" class="form-control celular"  value="{{old('celular')[$i] ??  "" }}" name="celular[{{$i}}]"  placeholder="Celular" />
+                                      @error('celular.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>
+                              <div class="col-md-12"><h5>Endereço</h5></div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'CEP'])
+                                      <input type="text" class="form-control" value="{{old('cep')[$i] ??  "" }}" name="cep[{{$i}}]"  placeholder="CEP" />
+                                      @error('cep.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>           
+                                                  
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Estado'])
+                                  <select name="uf[{{$i}}]"  id="estado" class="form-control"   style="visibility: visible" >
+                                    <option value=""  selected>-- Selecione uma opção --</option>
+                                    @foreach ($estados as $sigla => $nome)
+                                      <option @if(old('uf')[$i] ??  "" == $sigla ) selected @endif value="{{ $sigla }}">{{ $nome }}</option>
+                                    @endforeach
+                                  </select>
+                                  @error('uf.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                            @component('componentes.select', ['label' => 'Turno'])
-                              <select name="turno[]" class="form-control" required>
-                                <option value="" disabled selected>-- Selecione uma opção --</option>
-                                @foreach ($enum_turno as $key => $value)
-                                  <option @if($p->turno == $value ) selected @endif value="{{ $value }}">{{ $value }}</option>
-                                @endforeach
-                              </select>
-                            @endcomponent
-                          </div>
-                          @php
-                            $options = array('6' => 6, '7' => 7,'8' => 8,'9' => 9,'10' => 10,'11' => 11,'12' => 12); 
-                          @endphp                              
-                          <div class="col-6">
-                            @component('componentes.select', ['label' => 'Total de períodos do curso'])
-                              <select name="total_periodos[]"  class="form-control" onchange="gerarPeriodo(this)" required>
-                                <option value="" disabled selected>-- Selecione uma opção --</option>
-                                @foreach ($options as $key => $value)
-                                  <option @if($p->total_periodos == $key ) selected @endif value="{{ $key }}">{{ $value }}</option>
-                                @endforeach
-                              </select>
-                            @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                            @component('componentes.select', ['label' => 'Período atual'])
-                              <select name="periodo_atual[]"  class="form-control" required >
-                                <option value="" disabled selected>-- Selecione uma opção --</option>
-                                <option selected  value="{{ $p->periodo_atual }}">{{ $p->periodo_atual }}</option>
-                              </select>
-                            @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @php
-                                  $ordens = array('1' => 1, '2' => 2,'3' => 3,); 
-                                @endphp 
-                                @component('componentes.select', ['label' => 'Ordem de prioridade'])
-                                  <select name="ordem_prioridade[]"  class="form-control" required>
-                                    <option value="" disabled selected>-- ORDEM --</option>
-                                    @foreach ($ordens as $ordem)
-                                      <option @if($p->ordem_prioridade == $ordem) @endif selected  value="{{ $p->ordem_prioridade }}">{{ $p->ordem_prioridade }}</option>
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Cidade'])
+                                      <input type="text" class="form-control" value="{{old('cidade')[$i] ??  "" }}" name="cidade[{{$i}}]"  placeholder="Cidade" />
+                                      @error('cidade.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Bairro'])
+                                      <input type="text" class="form-control" value="{{old('bairro')[$i] ??  "" }}" name="bairro[{{$i}}]"  placeholder="Bairro" />
+                                      @error('bairro.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Rua'])
+                                      <input type="text" class="form-control" value="{{old('rua')[$i] ??  "" }}" name="rua[{{$i}}]" placeholder="Rua" />
+                                      @error('rua.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Número'])
+                                      <input type="text" class="form-control" value="{{old('numero')[$i] ??   "" }}" name="numero[{{$i}}]"  placeholder="Número" />
+                                      @error('numero.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-12">
+                                    @component('componentes.input', ['label' => 'Complemento',])
+                                      <input type="text" class="form-control" value="{{old('complemento')[$i] ??  "" }}" name="complemento[{{$i}}]"    placeholder="Complemento" />
+                                    @error('complemento.'.$i)
+                                      <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                        <strong>{{ $message }}</strong>
+                                      </span>
+                                    @enderror
+                                    @endcomponent
+                              </div>
+                              <div class="col-md-12"><h5>Dados do curso</h5></div>                               
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Universidade'])
+                                      <input type="text" class="form-control" value="{{old('instituicao')[$i] ??  "" }}" name="instituicao[{{$i}}]"  placeholder="Universidade" />
+                                      @error('instituicao.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Curso'])
+                                      <input type="text" class="form-control" value="{{old('curso')[$i] ??  "" }}" name="curso[{{$i}}]"  placeholder="Curso" />
+                                      @error('curso.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Turno'])
+                                  <select  name="turno[{{$i}}]"  class="form-control" >
+                                    <option value=""  selected>-- Selecione uma opção --</option>
+                                    @foreach ($enum_turno as $key => $value)
+                                      <option @if(old('turno')[$i] ??  "" == $value ) selected @endif value="{{ $value }}">{{ $value }}</option>
                                     @endforeach
                                   </select>
+                                  @error('turno.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Coeficiente de rendimento'])
-                                <input type="number" class="form-control media" value="{{ $p->media_do_curso }}" name="media_geral_curso[]" min="0" max="10" step="0.01"  required>
+                              </div>
+                              @php
+                                $options = array('6' => 6, '7' => 7,'8' => 8,'9' => 9,'10' => 10,'11' => 11,'12' => 12); 
+                              @endphp                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Total de períodos do curso'])
+                                  <select  name="total_periodos[{{$i}}]"   class="form-control" onchange="gerarPeriodo(this)" >
+                                    <option value=""  selected>-- Selecione uma opção --</option>
+                                    @foreach ($options as $key => $value)
+                                      <option @if(old('total_periodos')[$i]  ??  "" == $key ) selected @endif value="{{ $key }}">{{ $value }}</option>
+                                    @endforeach
+                                  </select>
+                                  @error('total_periodos.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>
-                          <div class="col-md-12"><h5>Plano de trabalho</h5></div>                              
-                          <div class="col-6">
-                            {{-- @dd($arquivos) --}}
-                                @component('componentes.input', ['label' => 'Título'])
-                                  <input type="text" class="form-control" value="{{ $arquivos[$loop->index]->titulo }}" name="nomePlanoTrabalho[]" placeholder="Digite o título do plano de trabalho" required>
+                              </div>                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Período atual'])
+                                  <select name="periodo_atual[]"  class="form-control"  >
+                                    <option selected value="{{ old('periodo_atual')[$i]  ?? "" }}">{{ old('periodo_atual')[$i]  ??  "" }}</option>
+                                  </select>
+                                  @error('periodo_atual.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                          </div>                              
-                          <div class="col-6">
-                                @component('componentes.input', ['label' => 'Anexo(.pdf)'])
-                                  <input type="file" class="input-group-text" value="{{ $arquivos[$loop->index]->titulo }}"  name="anexoPlanoTrabalho[]" accept=".pdf" placeholder="Anexo do Plano de Trabalho" />
+                              </div>                              
+                              <div class="col-6">
+                                @component('componentes.select', ['label' => 'Ordem de prioridade'])
+                                  <select name="ordem_prioridade[]"  class="form-control" >
+                                    <option value=""  selected>-- ORDEM --</option>
+                                    @for($j = 1; $j <= 3; $j++)
+                                      <option @if(old('ordem_prioridade')[$i]  ??  "" == $j ) selected @endif value="{{ $j }}">{{ $j }}</option>  
+                                    @endfor
+    
+                                  </select>
+                                  @error('ordem_prioridade.'.$i)
+                                    <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                      <strong>{{ $message }}</strong>
+                                    </span>
+                                  @enderror
                                 @endcomponent
-                                <div class="row justify-content-center">
-                                  <div class="col-3 ">
-                                    <a href="{{ route('baixar.plano', ['id' => $p->planoTrabalho->id]) }}">
-                                    <i class="fas fa-file-pdf fa-2x"></i></a>
-                                  </div>
-                                </div>
-                          </div>                              
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Coeficiente de rendimento'])
+                                    <input type="number" class="form-control media" value="{{old('media_do_curso')[$i] ??  "" }}" name="media_do_curso[{{$i}}]"  min="0" max="10" step="0.01"  >
+                                    @error('media_do_curso.'.$i)
+                                      <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                        <strong>{{ $message }}</strong>
+                                      </span>
+                                    @enderror
+                                    @endcomponent
+                              </div>
+                              <div class="col-md-12"><h5>Plano de trabalho</h5></div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Título'])
+                                      <input type="text" class="form-control" value="{{old('nomePlanoTrabalho')[$i] ??  "" }}" name="nomePlanoTrabalho[{{$i}}]"  placeholder="Digite o título do plano de trabalho" >
+                                      @error('nomePlanoTrabalho.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                              </div>                              
+                              <div class="col-6">
+                                    @component('componentes.input', ['label' => 'Anexo(.pdf)'])
+                                      <input type="file" class="input-group-text" value="{{old('anexoPlanoTrabalho')[$i] ?? "" }}" name="anexoPlanoTrabalho[{{$i}}]"  accept=".pdf" placeholder="Anexo do Plano de Trabalho" />
+                                      @error('anexoPlanoTrabalho.'.$i)
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                      @error('anexoPlanoTrabalho')
+                                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                                          <strong>{{ $message }}</strong>
+                                        </span>
+                                      @enderror
+                                    @endcomponent
+                                    {{-- <div class="row justify-content-center">
+                                      <div class="col-3 ">
+                                        <a href="{{ route('baixar.plano', ['id' => $p->planoTrabalho->id]) }}">
+                                        <i class="fas fa-file-pdf fa-2x"></i></a>
+                                      </div>
+                                    </div> --}}
+                              </div>                              
+                            </div>
                         </div>
+                      </div>
                     </div>
                   </div>
-                </div>
-                  
-              </div>
-            @endforeach
+                @endif
+              
+            @endfor
+            
           </div>
         </div>        
         
diff --git a/resources/views/projeto/editaFormulario/projeto.blade.php b/resources/views/projeto/editaFormulario/projeto.blade.php
index fae5954..adf75da 100644
--- a/resources/views/projeto/editaFormulario/projeto.blade.php
+++ b/resources/views/projeto/editaFormulario/projeto.blade.php
@@ -11,24 +11,24 @@
           <div class="col-md-12" style="margin-bottom: -0.8rem;"><hr style="border-top: 1px solid#1492E6"></div>
 
           <div class="form-group col-md-12" style="margin-top: 10px">
-              <label for="nomeProjeto" class="col-form-label">{{ __('Nome do Projeto') }} <span style="color: red; font-weight:bold">*</span></label>
-              <input id="nomeProjeto" type="text" class="form-control @error('nomeProjeto') is-invalid @enderror" name="nomeProjeto" placeholder="Digite o nome do projeto" value="{{ $projeto->titulo }}" autocomplete="nomeProjeto" required >
-              @error('nomeProjeto')
+              <label for="titulo" class="col-form-label">{{ __('Nome do Projeto') }} <span style="color: red; font-weight:bold">*</span></label>
+              <input id="titulo" type="text" class="form-control @error('titulo') is-invalid @enderror" name="titulo" placeholder="Digite o nome do projeto" value="{{old('titulo') ?? $projeto->titulo}}" autocomplete="titulo"  >
+              @error('titulo')
               <span class="invalid-feedback" role="alert">
                 <strong>{{ $message }}</strong>
               </span>
               @enderror
           </div>
-          {{-- @dd($projeto->grandeArea->nome) --}}
+
           <div class="form-group col-md-4">
             <label for="grandeArea" class="col-form-label">{{ __('Grande Área') }} <span style="color: red; font-weight:bold">*</span></label>
-              <select class="form-control @error('grandeArea') is-invalid @enderror" id="grandeArea" name="grandeArea" onchange="areas()" required>
+              <select class="form-control @error('grandeArea') is-invalid @enderror" id="grandeArea" name="grande_area_id" onchange="areas()" >
                 <option value="" disabled selected hidden>-- Grande Área --</option>
                 @foreach($grandeAreas as $grandeArea)
-                  <option @if($projeto->grandeArea->id ?? "" == $grandeArea->id ) selected @endif value="{{$grandeArea->id}}">{{$grandeArea->nome}}</option>
+                  <option @if($projeto->grande_area_id == $grandeArea->id ) selected @endif value="{{$grandeArea->id}}">{{$grandeArea->nome}}</option>
                 @endforeach
               </select>
-              @error('grandeArea')
+              @error('grande_area_id')
               <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                 <strong>{{ $message }}</strong>
               </span>
@@ -37,13 +37,12 @@
           <div class="form-group col-md-4">
             <label for="area" class="col-form-label">{{ __('Área') }} <span style="color: red; font-weight:bold">*</span></label>
               <input type="hidden" id="oldArea" value="{{ old('area') }}" >
-              <select class="form-control @error('area') is-invalid @enderror" id="area" name="area" onchange="subareas()" required>
+              <select class="form-control @error('area') is-invalid @enderror" id="area" name="area_id" onchange="subareas()" >
                 @foreach($areas as $area)
-                  <option @if($projeto->area->id ?? "" == $area->id ) selected @endif value="{{$area->id}}">{{$area->nome}}</option>
+                  <option @if($projeto->area_id == $area->id ) selected @endif value="{{$area->id}}">{{$area->nome}}</option>
                 @endforeach
-
               </select>
-              @error('area')
+              @error('area_id')
               <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                 <strong>{{ $message }}</strong>
               </span>
@@ -52,16 +51,15 @@
           <div class="form-group col-md-4">
             <label for="subArea" class="col-form-label">{{ __('Subárea') }} </label>
               <input type="hidden" id="oldSubArea" value="{{ old('subArea') }}" >
-              <select class="form-control @error('subArea') is-invalid @enderror" id="subArea" name="subArea" >
-                <option value="" disabled selected hidden>-- Subárea --</option>
-                @if ($projeto->subarea != null)
-                  @foreach($subareas as $subarea)
-                    <option @if($projeto->subarea->id ?? "" == $subarea->id ) selected @endif value="{{$subarea->id}}">{{$subarea->nome}}</option>
+              <select class="form-control @error('subArea') is-invalid @enderror" id="subArea" name="sub_area_id" >
+                <@if ($projeto->subarea != null)
+                  @foreach($subAreas as $subarea)
+                    <option @if($projeto->sub_area_id == $subarea->id ) selected @endif value="{{$subarea->id}}">{{$subarea->nome}}</option>
                   @endforeach
                 @endif
               </select>
 
-              @error('subArea')
+              @error('sub_area_id')
               <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                 <strong>{{ $message }}</strong>
               </span>
diff --git a/resources/views/projeto/editaFormulario/proponente.blade.php b/resources/views/projeto/editaFormulario/proponente.blade.php
index 65faa5b..3e09263 100644
--- a/resources/views/projeto/editaFormulario/proponente.blade.php
+++ b/resources/views/projeto/editaFormulario/proponente.blade.php
@@ -22,7 +22,7 @@
               value="{{ Auth()->user()->proponentes->linkLattes }}"
             @else
             value=""
-            @endif required >
+            @endif  >
             <small>Ex.: http://lattes.cnpq.br/8363536830656923</small>
             @error('linkLattesEstudante')
             <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
@@ -32,12 +32,12 @@
           </div>
           
           <div class="form-group col-md-6">
-            <label for="linkGrupo">Link do grupo de pesquisa</label>
-            <input class="form-control @error('linkGrupo') is-invalid @enderror" type="url" name="linkGrupo"
-                    value="{{ $projeto->linkGrupoPesquisa }}" required>
+            <label for="linkGrupoPesquisa">Link do grupo de pesquisa</label>
+            <input class="form-control @error('linkGrupoPesquisa') is-invalid @enderror" type="url" name="linkGrupoPesquisa"
+                    value="{{ $projeto->linkGrupoPesquisa }}" >
 
             <small>Ex.: http://dgp.cnpq.br/dgp/espelhogrupo/228363</small>
-            @error('linkGrupo')
+            @error('linkGrupoPesquisa')
             <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
               <strong>{{ $message }}</strong>
             </span>
@@ -46,7 +46,7 @@
           <div class="form-group col-md-6">
             <label for="pontuacaoPlanilha">Valor da planilha de pontuação <span style="color: red; font-weight:bold">*</span></label>
             <input class="form-control @error('pontuacaoPlanilha') is-invalid @enderror" type="number" min="0" name="pontuacaoPlanilha"
-            value="{{ $projeto->pontuacaoPlanilha }}"  required>
+            value="{{ $projeto->pontuacaoPlanilha }}"  >
 
             @error('pontuacaoPlanilha')
             <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
diff --git a/resources/views/projeto/editar.blade.php b/resources/views/projeto/editar.blade.php
index 71b384d..4f81542 100644
--- a/resources/views/projeto/editar.blade.php
+++ b/resources/views/projeto/editar.blade.php
@@ -4,34 +4,46 @@
 
 <div>
   {{-- action="{{route('trabalho.store')}}" --}}
-  <form method="POST" id="criarProjetoForm" action="{{route('trabalho.update', ['id' => $projeto->id])}}" enctype="multipart/form-data" >
+  <form method="POST" id="updateProjetoForm"  action="{{route('trabalho.update', ['id' => $projeto->id])}}" enctype="multipart/form-data" >
   @csrf
   <input type="hidden" name="editalId" value="{{$edital->id}}">
 
   <div class="container">
+    {{-- @dd($errors->get('name.*')) --}}
+    {{-- @dd($errors->has('cpf.*')) --}}
+    {{-- @dd($errors->getBags()['default']->keys()) --}}
     @if (session('mensagem'))
         <div class="alert alert-warning" role="alert">
             {{ session('mensagem') }}
         </div>
     @endif
+    @if ($errors->any())
+        <div class="alert alert-danger">
+            <ul>
+                @foreach ($errors->all() as $error)
+                    <li>{{ $error }}</li>
+                @endforeach
+            </ul>
+        </div>
+    @endif
+    
     <div class="row justify-content-center">
 
-      @component('projeto.editaFormulario.projeto', 
-                ['grandeAreas' => $grandeAreas, 'projeto' => $projeto,
-                 'areas' => $areas, 'subareas' => $subAreas])
-      @endcomponent
+      @include('projeto.editaFormulario.projeto')
+      
+      
+      @include('projeto.editaFormulario.proponente')
       
-      @component('projeto.editaFormulario.proponente', ['projeto' => $projeto])
-      @endcomponent
       
-      @component('projeto.editaFormulario.anexos', ['projeto' => $projeto])
-      @endcomponent
+      @include('projeto.editaFormulario.anexos')
       
-      @component('projeto.editaFormulario.participantes', ['estados' => $estados, 'enum_turno' => $enum_turno, 'projeto' => $projeto, 'participantes' => $participantes, 'arquivos' =>$arquivos])
-      @endcomponent
       
-      @component('projeto.editaFormulario.finalizar', ['projeto' => $projeto])
-      @endcomponent
+      @include('projeto.editaFormulario.participantes')
+      {{-- @include('projeto.editaFormulario.participantes', ['estados' => $estados, 'enum_turno' => $enum_turno, 'edital'=>$edital, 'projeto' => $projeto])
+       --}}
+      
+      @include('projeto.editaFormulario.finalizar')
+      
 
     </div>
   </div>
@@ -93,8 +105,10 @@
 
 
 <script>
+
     
   let buttonSubmit = document.getElementById('idButtonSubmitProjeto');
+  let buttonRascunho = document.getElementById('idButtonSubmitRascunho');
   let parts = document.getElementById('participante');
   let partsFirst = document.getElementById('participanteFirst');
   const participante = partsFirst.firstElementChild;
@@ -102,6 +116,12 @@
 
   buttonSubmit.addEventListener('click', (e)=>{
     $('.collapse').addClass('show')
+    
+  })
+  buttonRascunho.addEventListener('click', (e)=>{
+    $('.collapse').addClass('show')
+    const input = '<input id="input_rascunho" type="hidden" name="rascunho" value="true">';
+    $("#updateProjetoForm").append(input);
   })
 
   function gerarPeriodo(e){
@@ -123,7 +143,7 @@
         
       }else{
         parts.removeChild(e.parentElement.parentElement);
-        contador--;
+        //contador--;
       }
       
     }
@@ -142,19 +162,19 @@
       cln.children[2].firstElementChild.setAttribute('id', id + contador);
       cln.children[0].firstElementChild.setAttribute('href', "#collapseParticipante" + contador);
       cln.children[0].firstElementChild.setAttribute('id', id2 + contador);
-
+      
       for (i = 0; i < cln.children.length; i++) {
         for (let index = 0; index < cln.children[i].querySelectorAll('input').length; index++) {
           let input = cln.children[i].querySelectorAll('input')[index];
           let name = input.getAttributeNode("name").value;
           name = name.replace("[]", "");
-          // input.getAttributeNode("name").value = name + '['+ contador +']';
+          input.getAttributeNode("name").value = name + '['+ contador +']';
           let select = cln.children[i].querySelectorAll('select')[index];
           if(select){
             let selectName = select.getAttributeNode("name").value;
             selectName = selectName.replace("[", "");
             selectName = selectName.replace("]", "");
-            // select.getAttributeNode("name").value = selectName + '['+ contador +']';
+            select.getAttributeNode("name").value = selectName + '['+ contador +']';
           }
           
         }
@@ -168,9 +188,7 @@
           }
       };
       parts.appendChild(cln);
-      // console.log(cln);
-      $(cln).find(".cpf").val("").mask("000.000.000-00");
-      // $("input.cpf:text").val("").mask("000.000.000-00");
+      $("input.cpf:text").val("").mask("000.000.000-00");
       $("input.celular:text").val("").mask(SPMaskBehavior, spOptions);
       $("input.cep:text").val("").mask("00000-000");
 
@@ -228,145 +246,144 @@
 
     
 
-    $.validator.setDefaults( {
+    // $.validator.setDefaults( {
       
-      submitHandler: function (form) {
-        form.submit();
-      }
-    } );
-    jQuery.extend(jQuery.validator.messages, {
-        required: "Este campo &eacute; requerido.",
-        remote: "Por favor, corrija este campo.",
-        email: "Por favor, forne&ccedil;a um endere&ccedil;o eletr&ocirc;nico v&aacute;lido.",
-        url: "Por favor, forne&ccedil;a uma URL v&aacute;lida.",
-        date: "Por favor, forne&ccedil;a uma data v&aacute;lida.",
-        dateISO: "Por favor, forne&ccedil;a uma data v&aacute;lida (ISO).",
-        number: "Por favor, forne&ccedil;a um n&uacute;mero v&aacute;lido.",
-        digits: "Por favor, forne&ccedil;a somente d&iacute;gitos.",
-        creditcard: "Por favor, forne&ccedil;a um cart&atilde;o de cr&eacute;dito v&aacute;lido.",
-        equalTo: "Por favor, forne&ccedil;a o mesmo valor novamente.",
-        accept: "Por favor, forne&ccedil;a um valor com uma extens&atilde;o v&aacute;lida.",
-        maxlength: jQuery.validator.format("Por favor, forne&ccedil;a n&atilde;o mais que {0} caracteres."),
-        minlength: jQuery.validator.format("Por favor, forne&ccedil;a ao menos {0} caracteres."),
-        rangelength: jQuery.validator.format("Por favor, forne&ccedil;a um valor entre {0} e {1} caracteres de comprimento."),
-        range: jQuery.validator.format("Por favor, forne&ccedil;a um valor entre {0} e {1}."),
-        max: jQuery.validator.format("Por favor, forne&ccedil;a um valor menor ou igual a {0}."),
-        min: jQuery.validator.format("Por favor, forne&ccedil;a um valor maior ou igual a {0}.")
-    });
-    $( "#criarProjetoForm" ).validate( {
-      ignore: false,
-      lang: 'PT_BR',
-      rules: {
-        firstname: "required",
-        username: {
-          required: true,
-          minlength: 2
-        },
-        password: {
-          required: true,
-          minlength: 5
-        },
-        confirm_password: {
-          required: true,
-          minlength: 5,
-          equalTo: "#password"
-        },
-        email: {
-          required: true,
-          email: true,
+    //   submitHandler: function (form) {
+    //     form.submit();
+    //   }
+    // } );
+    // jQuery.extend(jQuery.validator.messages, {
+    //     required: "Este campo &eacute; requerido.",
+    //     remote: "Por favor, corrija este campo.",
+    //     email: "Por favor, forne&ccedil;a um endere&ccedil;o eletr&ocirc;nico v&aacute;lido.",
+    //     url: "Por favor, forne&ccedil;a uma URL v&aacute;lida.",
+    //     date: "Por favor, forne&ccedil;a uma data v&aacute;lida.",
+    //     dateISO: "Por favor, forne&ccedil;a uma data v&aacute;lida (ISO).",
+    //     number: "Por favor, forne&ccedil;a um n&uacute;mero v&aacute;lido.",
+    //     digits: "Por favor, forne&ccedil;a somente d&iacute;gitos.",
+    //     creditcard: "Por favor, forne&ccedil;a um cart&atilde;o de cr&eacute;dito v&aacute;lido.",
+    //     equalTo: "Por favor, forne&ccedil;a o mesmo valor novamente.",
+    //     accept: "Por favor, forne&ccedil;a um valor com uma extens&atilde;o v&aacute;lida.",
+    //     maxlength: jQuery.validator.format("Por favor, forne&ccedil;a n&atilde;o mais que {0} caracteres."),
+    //     minlength: jQuery.validator.format("Por favor, forne&ccedil;a ao menos {0} caracteres."),
+    //     rangelength: jQuery.validator.format("Por favor, forne&ccedil;a um valor entre {0} e {1} caracteres de comprimento."),
+    //     range: jQuery.validator.format("Por favor, forne&ccedil;a um valor entre {0} e {1}."),
+    //     max: jQuery.validator.format("Por favor, forne&ccedil;a um valor menor ou igual a {0}."),
+    //     min: jQuery.validator.format("Por favor, forne&ccedil;a um valor maior ou igual a {0}.")
+    // });
+    // $( "#criarProjetoForm" ).validate( {
+    //   lang: 'PT_BR',
+    //   rules: {
+    //     firstname: "required",
+    //     username: {
+    //       required: true,
+    //       minlength: 2
+    //     },
+    //     password: {
+    //       required: true,
+    //       minlength: 5
+    //     },
+    //     confirm_password: {
+    //       required: true,
+    //       minlength: 5,
+    //       equalTo: "#password"
+    //     },
+    //     email: {
+    //       required: true,
+    //       email: true,
           
-        },
-        "complemento[]":{
+    //     },
+    //     "complemento[]":{
 
           
-        },
-        "nomeParticipante[]":{
-          required:true,
-          alpha:true,
-        },
-        'rg[]':{
-          required: true,
-          maxlength: 12,
-        },
+    //     },
+    //     "nomeParticipante[]":{
+          
+    //       alpha:true,
+    //     },
+    //     'rg[]':{
+          
+    //       maxlength: 12,
+    //     },
         
-        agree: "required"
-      },
-      messages: {
-        // nomeProjeto: "O nome do projeto é obrigatório.",
+    //     agree: "required"
+    //   },
+    //   messages: {
+    //     // nomeProjeto: "O nome do projeto é obrigatório.",
         
-        // 'emailParticipante[]': "Este campo é obrigatório.",
-        // 'data_de_nascimento[]': "Este campo é obrigatório.",
-        // 'cpf[]': "Este campo é obrigatório.",
-        // 'rg[]': {
-        //   required: "Este campo é obrigatório.",
-        //   maxlength: "Este campo deve conter no máximo 8 números."
-        // },
-        // 'celular[]': "Este campo é obrigatório.",
-        // 'cep[]': "Este campo é obrigatório.",
-        // 'uf[]': "Este campo é obrigatório.",
-        // 'cidade[]': "Este campo é obrigatório.",
-        // 'bairro[]': "Este campo é obrigatório.",
-        // 'rua[]': "Este campo é obrigatório.",
-        // 'numero[]': "Este campo é obrigatório.",
-        // 'complemento[]': "Este campo é obrigatório.",
-        // 'universidade[]': "Este campo é obrigatório.",
-        // 'curso[]': "Este campo é obrigatório.",
-        // 'turno[]': "Este campo é obrigatório.",
-        // 'total_periodos[]': "Este campo é obrigatório.",
-        // 'periodo_atual[]': "Este campo é obrigatório.",
-        // 'ordem_prioridade[]': "Este campo é obrigatório.",
-        // 'media_geral_curso[]': "Este campo é obrigatório.",
-        // 'nomePlanoTrabalho[]': "Este campo é obrigatório.",
-        // 'anexoPlanoTrabalho[]': "Este campo é obrigatório.",
-        // grandeArea: "Escolha uma grande área.",
-        // area: "Escolha uma área.",
-        // linkGrupo: "Este campo é obrigatório.",
-        // pontuacaoPlanilha: "Este campo é obrigatório.",
-        // anexoProjeto: "Este campo é obrigatório.",
-        // anexoLattesCoordenador: "Este campo é obrigatório.",
-        // anexoConsuPreenchido: "Este campo é obrigatório.",
-        // anexoGrupoPesquisa: "Este campo é obrigatório.",
-        // anexoPlanilha: "Este campo é obrigatório.",
-        // anexoComiteEtica: "Este campo é obrigatório.",
-        // inputJustificativa: "Este campo é obrigatório.",
-        // "nomeParticipante[]": {
-        //   required: "O nome do participante é obrigatório.",
-        //   alpha: "Não é permitido números."
-        // },
-        // username: {
-        //   required: "Please enter a username",
-        //   minlength: "Your username must consist of at least 2 characters"
-        // },
-        // password: {
-        //   required: "Please provide a password",
-        //   minlength: "Your password must be at least 5 characters long"
-        // },
-        // confirm_password: {
-        //   required: "Please provide a password",
-        //   minlength: "Your password must be at least 5 characters long",
-        //   equalTo: "Please enter the same password as above"
-        // },
-        // email: "Please enter a valid email address",
-        // agree: "Please accept our policy"
-      },
-      errorElement: "em",
-      errorPlacement: function ( error, element ) {
-        // Add the `help-block` class to the error element
-        error.addClass( "invalid-feedback" );
-
-        if ( element.prop( "type" ) === "checkbox" ) {
-          error.insertAfter( element.parent( "label" ) );
-        } else {
-          error.insertAfter( element );
-        }
-      },
-      highlight: function ( element, errorClass, validClass ) {
-        $( element ).parents( ".col-sm-5" ).addClass( "has-error" ).removeClass( "has-success" );
-      },
-      unhighlight: function (element, errorClass, validClass) {
-        $( element ).parents( ".col-sm-5" ).addClass( "has-success" ).removeClass( "has-error" );
-      }
-    } );
+    //     // 'emailParticipante[]': "Este campo é obrigatório.",
+    //     // 'data_de_nascimento[]': "Este campo é obrigatório.",
+    //     // 'cpf[]': "Este campo é obrigatório.",
+    //     // 'rg[]': {
+    //     //   required: "Este campo é obrigatório.",
+    //     //   maxlength: "Este campo deve conter no máximo 8 números."
+    //     // },
+    //     // 'celular[]': "Este campo é obrigatório.",
+    //     // 'cep[]': "Este campo é obrigatório.",
+    //     // 'uf[]': "Este campo é obrigatório.",
+    //     // 'cidade[]': "Este campo é obrigatório.",
+    //     // 'bairro[]': "Este campo é obrigatório.",
+    //     // 'rua[]': "Este campo é obrigatório.",
+    //     // 'numero[]': "Este campo é obrigatório.",
+    //     // 'complemento[]': "Este campo é obrigatório.",
+    //     // 'universidade[]': "Este campo é obrigatório.",
+    //     // 'curso[]': "Este campo é obrigatório.",
+    //     // 'turno[]': "Este campo é obrigatório.",
+    //     // 'total_periodos[]': "Este campo é obrigatório.",
+    //     // 'periodo_atual[]': "Este campo é obrigatório.",
+    //     // 'ordem_prioridade[]': "Este campo é obrigatório.",
+    //     // 'media_geral_curso[]': "Este campo é obrigatório.",
+    //     // 'nomePlanoTrabalho[]': "Este campo é obrigatório.",
+    //     // 'anexoPlanoTrabalho[]': "Este campo é obrigatório.",
+    //     // grandeArea: "Escolha uma grande área.",
+    //     // area: "Escolha uma área.",
+    //     // linkGrupo: "Este campo é obrigatório.",
+    //     // pontuacaoPlanilha: "Este campo é obrigatório.",
+    //     // anexoProjeto: "Este campo é obrigatório.",
+    //     // anexoLattesCoordenador: "Este campo é obrigatório.",
+    //     // anexoConsuPreenchido: "Este campo é obrigatório.",
+    //     // anexoGrupoPesquisa: "Este campo é obrigatório.",
+    //     // anexoPlanilha: "Este campo é obrigatório.",
+    //     // anexoComiteEtica: "Este campo é obrigatório.",
+    //     // inputJustificativa: "Este campo é obrigatório.",
+    //     // "nomeParticipante[]": {
+    //     //   required: "O nome do participante é obrigatório.",
+    //     //   alpha: "Não é permitido números."
+    //     // },
+    //     // username: {
+    //     //   required: "Please enter a username",
+    //     //   minlength: "Your username must consist of at least 2 characters"
+    //     // },
+    //     // password: {
+    //     //   required: "Please provide a password",
+    //     //   minlength: "Your password must be at least 5 characters long"
+    //     // },
+    //     // confirm_password: {
+    //     //   required: "Please provide a password",
+    //     //   minlength: "Your password must be at least 5 characters long",
+    //     //   equalTo: "Please enter the same password as above"
+    //     // },
+    //     // email: "Please enter a valid email address",
+    //     // agree: "Please accept our policy"
+    //   },
+    //   errorElement: "em",
+    //   errorPlacement: function ( error, element ) {
+    //     // Add the `help-block` class to the error element
+    //     error.addClass( "invalid-feedback" );
+
+    //     if ( element.prop( "type" ) === "checkbox" ) {
+    //       error.insertAfter( element.parent( "label" ) );
+    //     } else {
+    //       error.insertAfter( element );
+    //     }
+    //   },
+    //   highlight: function ( element, errorClass, validClass ) {
+    //     $( element ).parents( ".col-sm-5" ).addClass( "has-error" ).removeClass( "has-success" );
+    //   },
+    //   unhighlight: function (element, errorClass, validClass) {
+    //     $( element ).parents( ".col-sm-5" ).addClass( "has-success" ).removeClass( "has-error" );
+    //   }
+    // } );
     
   } );
 </script>
@@ -650,11 +667,11 @@
   }
 
   function submeterProposta() {
+    if (checarCpfs()) {
       document.getElementById("submeterFormProposta").click();
-    // if (checarCpfs()) {
-    // } else {
-    //   $("#modalCpfInvalido").modal('show');
-    // }
+    } else {
+      $("#modalCpfInvalido").modal('show');
+    }
   }
 
   function mascaraCPF(input) {
@@ -680,4 +697,4 @@
     input.value = resultado;
   }
 </script>
-@endsection
+@endsection
\ No newline at end of file
diff --git a/resources/views/projeto/formularioVisualizar/anexos.blade.php b/resources/views/projeto/formularioVisualizar/anexos.blade.php
index a0c6947..dbe7557 100644
--- a/resources/views/projeto/formularioVisualizar/anexos.blade.php
+++ b/resources/views/projeto/formularioVisualizar/anexos.blade.php
@@ -15,9 +15,15 @@
                 @component('componentes.input', ['label' => 'Projeto (.pdf)'])
                 @endcomponent
               </div>
-              <div class="col-2 ">
-                <a href="{{ route('baixar.anexo.projeto', ['id' => $projeto->id])}}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoProjeto)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexo.projeto', ['id' => $projeto->id])}}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           {{-- Anexo do currículo --}}
@@ -28,9 +34,15 @@
                   
                 @endcomponent
               </div>
-              <div class="col-2 ">
-                <a href="{{ route('baixar.anexo.lattes', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoLattesCoordenador)
+                <div class="col-2 ">
+                  <a href="{{ route('baixar.anexo.lattes', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-2 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           {{-- Anexo da Planilha de Pontuação --}}
@@ -41,9 +53,15 @@
                   
                 @endcomponent
               </div>
-              <div class="col-2 ">
-                <a href="{{ route('baixar.anexo.planilha', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoPlanilhaPontuacao)
+                <div class="col-2 ">
+                  <a href="{{ route('baixar.anexo.planilha', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-2 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           
@@ -51,13 +69,24 @@
           <div class="form-group col-md-6" style="margin-top: 10px">
             <div class="row justify-content-start">
               <div class="col-10">
-                @component('componentes.input', ['label' => 'Decisão do CONSU (.pdf)'])
+                
+                <div class="form-group">
+                  <label class=" control-label" for="firstname">Decisão do CONSU (.pdf)</label>
                   
-                @endcomponent
-              </div>
-              <div class="col-2 ">
-                <a href="{{ route('baixar.anexo.consu', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                  <div class="">
+                    
+                  </div>
+                </div>
               </div>
+              @if($projeto->anexoDecisaoCONSU)
+                <div class="col-2 ">
+                  <a href="{{ route('baixar.anexo.consu', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-2 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           
@@ -69,9 +98,15 @@
                   
                 @endcomponent
               </div>
-              <div class="col-2 ">
-                <a href="{{ route('baixar.anexoGrupoPesquisa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              @if($projeto->anexoGrupoPesquisa)
+                <div class="col-3 ">
+                  <a href="{{ route('baixar.anexoGrupoPesquisa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                </div>
+              @else
+                <div class="col-3 text-danger">
+                  <p><i class="fas fa-times-circle fa-2x"></i></p>
+                </div>
+              @endif
             </div>
           </div>
           {{-- Anexo da autorizações especiais  --}}
@@ -84,9 +119,9 @@
                     <label for="botao" class="col-form-label @error('botao') is-invalid @enderror" data-toggle="tooltip" data-placement="bottom" title="Se possuir, coloque todas em único arquivo pdf." style="margin-right: 15px;">{{ __('Possui autorizações especiais?') }} <span style="color: red; font-weight:bold">*</span></label>
                   </div>
                   <div class="col-12">
-                    <input type="radio" checked id="radioSim" disabled onchange="displayAutorizacoesEspeciais('sim')">
+                    <input type="radio" checked id="radioSim"  onchange="displayAutorizacoesEspeciais('sim')">
                     <label for="radioSim" style="margin-right: 5px">Sim</label>
-                    <input type="radio" id="radioNao" disabled onchange="displayAutorizacoesEspeciais('nao')">
+                    <input type="radio" id="radioNao"  onchange="displayAutorizacoesEspeciais('nao')">
                     <label for="radioNao" style="margin-right: 5px">Não</label><br>
                   </div>
                 </div>
@@ -97,18 +132,52 @@
                 <div class="form-group" id="displaySim" style="display: block; margin-top:-1rem">
                   @component('componentes.input', ['label' => 'Sim, declaro que necessito de autorizações especiais (.pdf)'])
                     
+                    <div class="row justify-content-center">
+                      @if($projeto->anexoAutorizacaoComiteEtica ) 
+                        <div class="col-3 mt-2">
+                          <a href="{{ route('baixar.anexo.comite', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                        </div>
+                      @else
+                          <div class="col-3 text-danger">
+                            <p><i class="fas fa-times-circle fa-2x"></i></p>
+                          </div>
+                      @endif
+                      
+                    </div>
+                    @error('anexoAutorizacaoComiteEtica')
+                      <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                        <strong>{{ $message }}</strong>
+                      </span>
+                    @enderror
                   @endcomponent
                 </div>
-
+    
                 <div class="form-group" id="displayNao" style="display: none; margin-top:-1rem">
                   @component('componentes.input', ['label' => 'Declaração de que não necessito de autorização especiais (.pdf)'])
                     
-                  @endcomponent
+                      @if($projeto->justificativaAutorizacaoEtica  ) 
+                      <div class="row justify-content-center">
+                        <div class="col-3 mt-2">
+                          <a href="{{ route('baixar.anexo.justificativa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
+                        </div>
+                      </div>
+                      @else
+                      <div class="row justify-content-center">
+                        <div class="col-3 text-danger">
+                          <p><i class="fas fa-times-circle fa-2x"></i></p>
+                        </div>
+                      </div>
+                      @endif
+                    
+                      @error('justificativaAutorizacaoEtica')
+                        <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
+                          <strong>{{ $message }}</strong>
+                        </span>
+                      @enderror
+                    @endcomponent
                 </div>
               </div>
-              <div class="col-2 mt-2">
-                <a href="{{ route('baixar.anexo.justificativa', ['id' => $projeto->id]) }}"><i class="fas fa-file-pdf fa-2x"></i></a>
-              </div>
+              
             </div>
            
           </div>
diff --git a/resources/views/projeto/formularioVisualizar/participantes.blade.php b/resources/views/projeto/formularioVisualizar/participantes.blade.php
index 85441ba..a24b14e 100644
--- a/resources/views/projeto/formularioVisualizar/participantes.blade.php
+++ b/resources/views/projeto/formularioVisualizar/participantes.blade.php
@@ -75,7 +75,7 @@
                           <div class="col-md-12"><h5>Endereço</h5></div>                              
                           <div class="col-6">
                                 @component('componentes.input', ['label' => 'CEP'])
-                                  <input type="number" class="form-control" value="{{ $p->user->endereco->cep }}" name="cep[]" placeholder="CEP" disabled/>
+                                  <input type="text" class="form-control" value="{{ $p->user->endereco->cep }}" name="cep[]" placeholder="CEP" disabled/>
                                 @endcomponent
                           </div>           
                                             
@@ -189,11 +189,18 @@
                                 </div>
                               </div>
                               <div class="row justify-content-center">
-                                <div class="col-3 ">
-                                    <a href="{{ route('baixar.plano', ['id' => $p->planoTrabalho->id]) }}">
-                                    <i class="fas fa-file-pdf fa-2x"></i></a>
+                                
+                                @if($p->planoTrabalho) 
+                                  <div class="col-3 ">
+                                      <a href="{{ route('baixar.plano', ['id' => $p->planoTrabalho->id]) }}">
+                                      <i class="fas fa-file-pdf fa-2x"></i></a>
+                                    </div>
                                   </div>
-                                </div>
+                                @else
+                                  <div class="col-3 text-danger">
+                                    <p><i class="fas fa-times-circle fa-2x"></i></p>
+                                  </div>
+                                @endif
                           </div>                              
                         </div>
                     </div>
diff --git a/resources/views/projeto/formularioVisualizar/projeto.blade.php b/resources/views/projeto/formularioVisualizar/projeto.blade.php
index 9482f04..1ea0865 100644
--- a/resources/views/projeto/formularioVisualizar/projeto.blade.php
+++ b/resources/views/projeto/formularioVisualizar/projeto.blade.php
@@ -25,7 +25,7 @@
               <select class="form-control @error('grandeArea') is-invalid @enderror" id="grandeArea" name="grandeArea" onchange="areas()" disabled>
                 <option value="" disabled selected hidden>-- Grande Área --</option>
                 @foreach($grandeAreas as $grandeArea)
-                  <option @if($projeto->grandeArea->id == $grandeArea->id ) selected @endif value="{{$grandeArea->id}}">{{$grandeArea->nome}}</option>
+                  <option @if($projeto->grande_area_id == $grandeArea->id ) selected @endif value="{{$grandeArea->id}}">{{$grandeArea->nome}}</option>
                 @endforeach
               </select>
               @error('grandeArea')
@@ -39,7 +39,7 @@
               <input type="hidden" id="oldArea" value="{{ old('area') }}" >
               <select class="form-control @error('area') is-invalid @enderror" id="area" name="area" onchange="subareas()" disabled>
                 @foreach($areas as $area)
-                  <option @if($projeto->area->id == $area->id ) selected @endif value="{{$area->id}}">{{$area->nome}}</option>
+                  <option @if($projeto->area_id == $area->id ) selected @endif value="{{$area->id}}">{{$area->nome}}</option>
                 @endforeach
 
               </select>
@@ -56,7 +56,7 @@
                 <option value="" disabled selected hidden>-- Subárea --</option>
                 @if ($projeto->subarea != null)
                   @foreach($subareas as $subarea)
-                    <option @if($projeto->subarea->id == $subarea->id ) selected @endif value="{{$subarea->id}}">{{$subarea->nome}}</option>
+                    <option @if($projeto->sub_area_id == $subarea->id ) selected @endif value="{{$subarea->id}}">{{$subarea->nome}}</option>
                   @endforeach
                 @endif
               </select>
diff --git a/routes/web.php b/routes/web.php
index e8e2048..cfa26c5 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,4 +1,4 @@
-<?php
+  <?php
 
 use App\Http\Middleware\checkCoordenador;
 use App\Trabalho;
@@ -33,21 +33,21 @@ Auth::routes(['verify' => true]);
 
 
 
-//######### Proponente  ########################################
-Route::get( '/proponente/index',      'ProponenteController@index'                  )->name('proponente.index');
-Route::get( '/proponente/cadastro',   'ProponenteController@create'                 )->name('proponente.create');
-Route::post('/proponente/cadastro',   'ProponenteController@store'                  )->name('proponente.store');
-Route::get( '/proponente/editais',    'ProponenteController@editais'                )->name('proponente.editais');
-Route::get( '/projetos-submetidos',   'ProponenteController@projetosDoProponente'   )->name('proponente.projetos');
-Route::get( '/projetos-edital/{id}',       'ProponenteController@projetosEdital'         )->name('proponente.projetosEdital')->middleware('auth');
-
-
-//######### Rotas Administrador #################################
-Route::get('/perfil-usuario',                  'UserController@minhaConta'        )->name('user.perfil')->middleware(['auth', 'verified']);
-Route::post('/perfil-usuario',                 'UserController@editarPerfil'      )->name('perfil.edit')->middleware(['auth', 'verified']);
 
 
 Route::group(['middleware' => ['isTemp', 'auth', 'verified']], function(){
+  //######### Proponente  ########################################
+  Route::get( '/proponente/index',      'ProponenteController@index'                  )->name('proponente.index');
+  Route::get( '/proponente/cadastro',   'ProponenteController@create'                 )->name('proponente.create');
+  Route::post('/proponente/cadastro',   'ProponenteController@store'                  )->name('proponente.store');
+  Route::get( '/proponente/editais',    'ProponenteController@editais'                )->name('proponente.editais');
+  Route::get( '/projetos-submetidos',   'ProponenteController@projetosDoProponente'   )->name('proponente.projetos');
+  Route::get( '/projetos-edital/{id}',       'ProponenteController@projetosEdital'         )->name('proponente.projetosEdital')->middleware('auth');
+  
+  
+  //######### Rotas Administrador #################################
+  Route::get('/perfil-usuario',                  'UserController@minhaConta'        )->name('user.perfil')->middleware(['auth', 'verified']);
+  Route::post('/perfil-usuario',                 'UserController@editarPerfil'      )->name('perfil.edit')->middleware(['auth', 'verified']);
 
   //######## Rotas Avaliador  ####################################
   Route::prefix('avaliador')->name('avaliador.')->group(function(){
@@ -123,7 +123,7 @@ Route::group(['middleware' => ['isTemp', 'auth', 'verified']], function(){
   Route::get(   '/edital/{id}/projetos',    'TrabalhoController@projetosDoEdital'           )->name('projetos.edital');
   Route::get(   '/projeto/visualizar/{id}', 'TrabalhoController@show'                       )->name('trabalho.show');
   Route::get(   '/projeto/{id}/editar',     'TrabalhoController@edit'                       )->name('trabalho.editar');
-  Route::post(   '/projeto/{id}/atualizar', 'TrabalhoController@atualizar'                  )->name('trabalho.update');
+  Route::post(   '/projeto/{id}/atualizar', 'TrabalhoController@update'                  )->name('trabalho.update');
   Route::get(   '/projeto/{id}/excluir',    'TrabalhoController@destroy'                    )->name('trabalho.destroy');
   Route::get(   '/projeto/{id}/excluirParticipante','TrabalhoController@excluirParticipante')->name('trabalho.excluirParticipante');
   Route::get(   '/projeto/exportar/{id}','TrabalhoController@exportProjeto'                 )->name('exportar.projeto');
-- 
GitLab