diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index e219498790443401d1e83e57ee7b68f67714c61f..52126df674b456f2b0b13b12c24ac572b3686ec4 100644 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -79,7 +79,7 @@ class TrabalhoController extends Controller //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); + //dd($coordenador->id); $trabalho = "trabalho"; if($evento->inicioSubmissao > $mytime){ if($mytime >= $evento->fimSubmissao){ @@ -287,6 +287,8 @@ class TrabalhoController extends Controller $subareas = Subarea::all(); $funcaoParticipantes = FuncaoParticipantes::all(); $participantes = Participante::where('trabalho_id', $id)->get(); + $participantesUsersIds = Participante::where('trabalho_id', $id)->select('user_id')->get(); + $users = User::whereIn('id', $participantesUsersIds)->get(); $arquivos = Arquivo::where('trabalhoId', $id)->get(); return view('projeto.editar')->with(['projeto' => $projeto, @@ -294,6 +296,7 @@ class TrabalhoController extends Controller 'areas' => $areas, 'subAreas' => $subareas, 'edital' => $edital, + 'users' => $users, 'funcaoParticipantes' => $funcaoParticipantes, 'participantes' => $participantes, 'arquivos' => $arquivos,]); @@ -401,10 +404,11 @@ class TrabalhoController extends Controller $trabalho->update(); // criando novos participantes que podem ter sido adicionados - $participantes = Participante::where('trabalho_id', $trabalho->id)->get(); + $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get(); + $users = User::whereIn('id', $participantesUsersIds)->get(); $emailParticipantes = []; - foreach ($participantes as $participante) { - array_push($emailParticipantes, $participante->user->email); + foreach ($users as $user) { + array_push($emailParticipantes, $user->email); } foreach ($request->emailParticipante as $key => $value) { @@ -443,7 +447,7 @@ class TrabalhoController extends Controller //atualizando os participantes que já estão no projeto e planos de trabalho se enviados if (in_array($request->emailParticipante[$key], $emailParticipantes, false)) { $user = User::where('email', $request->emailParticipante[$key])->first(); - $participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]]); + $participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first(); $user->name = $request->nomeParticipante[$key]; $user->update(); @@ -451,34 +455,37 @@ class TrabalhoController extends Controller $participante->funcao_participante_id = $request->funcaoParticipante[$key]; $participante->update(); - // //atualizando planos de trabalho incompleto - // dd($request); - // if (!(is_null($request->anexoPlanoTrabalho[1]))) { - // $arquivo = Arquivo::where('participanteId', $participante->id)->first(); - // Storage::delete($arquivo->nome); - // $arquivo->delete(); - - // $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/'; - // $nome = $request->nomePlanoTrabalho[$key] .".pdf"; - // $file = $request->anexoPlanoTrabalho[$key]; - // Storage::putFileAs($path, $file, $nome); - - // $arquivo = new Arquivo(); - // $arquivo->nome = $path . $nome; - // $arquivo->trabalhoId = $trabalho->id; - // $arquivo->data = $mytime; - // $arquivo->participanteId = $participante->id; - // $arquivo->versaoFinal = true; - // $arquivo->save(); - // } + //atualizando planos de trabalho + if (array_key_exists($key, $request->anexoPlanoTrabalho)) { + if (!(is_null($request->anexoPlanoTrabalho[$key]))) { + $arquivo = Arquivo::where('participanteId', $participante->id)->first(); + Storage::delete($arquivo->nome); + $arquivo->delete(); + + $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/'; + $nome = $request->nomePlanoTrabalho[$key] .".pdf"; + $file = $request->anexoPlanoTrabalho[$key]; + Storage::putFileAs($path, $file, $nome); + + $arquivo = new Arquivo(); + $arquivo->nome = $path . $nome; + $arquivo->trabalhoId = $trabalho->id; + $arquivo->data = $mytime; + $arquivo->participanteId = $participante->id; + $arquivo->versaoFinal = true; + $arquivo->save(); + } + } } } // Atualizando possiveis usuários removidos - $participantes = Participante::where('trabalho_id', $trabalho->id)->get(); + $participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get(); + $users = User::whereIn('id', $participantesUsersIds)->get(); - foreach ($participantes as $participante) { - if (!(in_array($participante->user->email, $request->emailParticipante, false))) { + 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); Storage::delete($arquivo->nome); $arquivo->delete(); diff --git a/composer.lock b/composer.lock index 3c89259638b85f00e2bbf2de86e92bbd5b952a39..321d82aba5f4a905480e52b555d28dbbb59f500f 100644 --- a/composer.lock +++ b/composer.lock @@ -1215,16 +1215,16 @@ }, { "name": "opis/closure", - "version": "3.5.3", + "version": "3.5.4", "source": { "type": "git", "url": "https://github.com/opis/closure.git", - "reference": "cac47092144043d5d676e2e7cf8d0d2f83fc89ca" + "reference": "1d0deef692f66dae5d70663caee2867d0971306b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opis/closure/zipball/cac47092144043d5d676e2e7cf8d0d2f83fc89ca", - "reference": "cac47092144043d5d676e2e7cf8d0d2f83fc89ca", + "url": "https://api.github.com/repos/opis/closure/zipball/1d0deef692f66dae5d70663caee2867d0971306b", + "reference": "1d0deef692f66dae5d70663caee2867d0971306b", "shasum": "" }, "require": { @@ -1272,7 +1272,7 @@ "serialization", "serialize" ], - "time": "2020-05-25T09:32:45+00:00" + "time": "2020-06-07T11:41:29+00:00" }, { "name": "paragonie/random_compat", @@ -1321,16 +1321,16 @@ }, { "name": "phpoption/phpoption", - "version": "1.7.3", + "version": "1.7.4", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae" + "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/4acfd6a4b33a509d8c88f50e5222f734b6aeebae", - "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", "shasum": "" }, "require": { @@ -1372,7 +1372,7 @@ "php", "type" ], - "time": "2020-03-21T18:07:53+00:00" + "time": "2020-06-07T10:40:07+00:00" }, { "name": "psr/container", @@ -3316,27 +3316,27 @@ }, { "name": "vlucas/phpdotenv", - "version": "v3.6.5", + "version": "v3.6.6", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "8b64814b356b96a90d2bc942b152c80d8888b8d4" + "reference": "4669484ccbc38fe7c4e0c50456778f2010566aad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8b64814b356b96a90d2bc942b152c80d8888b8d4", - "reference": "8b64814b356b96a90d2bc942b152c80d8888b8d4", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/4669484ccbc38fe7c4e0c50456778f2010566aad", + "reference": "4669484ccbc38fe7c4e0c50456778f2010566aad", "shasum": "" }, "require": { "php": "^5.4 || ^7.0 || ^8.0", - "phpoption/phpoption": "^1.5", - "symfony/polyfill-ctype": "^1.9" + "phpoption/phpoption": "^1.5.2", + "symfony/polyfill-ctype": "^1.16" }, "require-dev": { "ext-filter": "*", "ext-pcre": "*", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0" }, "suggest": { "ext-filter": "Required to use the boolean validator.", @@ -3375,7 +3375,7 @@ "env", "environment" ], - "time": "2020-05-23T09:42:03+00:00" + "time": "2020-06-02T14:08:54+00:00" } ], "packages-dev": [ diff --git a/resources/views/administrador/index.blade.php b/resources/views/administrador/index.blade.php index 17f67e4b97b5ef398d9e263560f199e7d7722b06..365296953b179e12fdeb06ed397b157d52b59758 100644 --- a/resources/views/administrador/index.blade.php +++ b/resources/views/administrador/index.blade.php @@ -26,7 +26,18 @@ - + + +
+