Commit 8d8c01d4 authored by Gabriel-31415's avatar Gabriel-31415
Browse files

ajuste do validate de trabalho

parent 13b64bc4
...@@ -75,7 +75,7 @@ class TrabalhoController extends Controller ...@@ -75,7 +75,7 @@ class TrabalhoController extends Controller
//Relaciona o projeto criado com o proponente que criou o projeto //Relaciona o projeto criado com o proponente que criou o projeto
$proponente = Proponente::where('user_id', Auth::user()->id)->first(); $proponente = Proponente::where('user_id', Auth::user()->id)->first();
//$trabalho->proponentes()->save($proponente); //$trabalho->proponentes()->save($proponente);
//dd($coordenador->id); //dd($request->all());
$trabalho = "trabalho"; $trabalho = "trabalho";
if($evento->inicioSubmissao > $mytime){ if($evento->inicioSubmissao > $mytime){
if($mytime >= $evento->fimSubmissao){ if($mytime >= $evento->fimSubmissao){
...@@ -98,7 +98,7 @@ class TrabalhoController extends Controller ...@@ -98,7 +98,7 @@ class TrabalhoController extends Controller
'nomeParticipante.*' => ['required', 'string'], 'nomeParticipante.*' => ['required', 'string'],
'emailParticipante.*' => ['required', 'string'], 'emailParticipante.*' => ['required', 'string'],
'funcaoParticipante.*' => ['required', 'string'], 'funcaoParticipante.*' => ['required', 'string'],
'nomePlanoTrabalho.*' => ['required', 'string'], 'nomePlanoTrabalho.*' => ['nullable', 'string'],
'anexoProjeto' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoProjeto' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoCONSU' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoCONSU' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'botao' => ['required'], 'botao' => ['required'],
...@@ -147,11 +147,11 @@ class TrabalhoController extends Controller ...@@ -147,11 +147,11 @@ class TrabalhoController extends Controller
'nomeParticipante.*' => ['required', 'string'], 'nomeParticipante.*' => ['required', 'string'],
'emailParticipante.*' => ['required', 'string'], 'emailParticipante.*' => ['required', 'string'],
'funcaoParticipante.*' => ['required', 'string'], 'funcaoParticipante.*' => ['required', 'string'],
'nomePlanoTrabalho.*' => ['required', 'string'], 'nomePlanoTrabalho.*' => ['nullable', 'string'],
'anexoProjeto' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoProjeto' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoLatterCoordenador' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoLatterCoordenador' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanilha' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoPlanilha' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanoTrabalho.*' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoPlanoTrabalho.*' => ['nullable', 'file', 'mimes:pdf', 'max:2000000'],
]); ]);
$trabalho = Trabalho::create([ $trabalho = Trabalho::create([
...@@ -218,21 +218,23 @@ class TrabalhoController extends Controller ...@@ -218,21 +218,23 @@ class TrabalhoController extends Controller
->send(new SubmissaoTrabalho($userParticipante, $subject, $evento, $trabalho)); ->send(new SubmissaoTrabalho($userParticipante, $subject, $evento, $trabalho));
} }
$usuario = User::where('email', $value)->first(); if($request->nomePlanoTrabalho[$key] != null){
$participante = Participante::where([['user_id', '=', $usuario->id], ['trabalho_id', '=', $trabalho->id]])->first(); $usuario = User::where('email', $value)->first();
$path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/'; $participante = Participante::where([['user_id', '=', $usuario->id], ['trabalho_id', '=', $trabalho->id]])->first();
$nome = $request->nomePlanoTrabalho[$key] .".pdf"; $path = 'trabalhos/' . $request->editalId . '/' . $trabalho->id .'/';
$file = $request->anexoPlanoTrabalho[$key]; $nome = $request->nomePlanoTrabalho[$key] .".pdf";
Storage::putFileAs($path, $file, $nome); $file = $request->anexoPlanoTrabalho[$key];
Storage::putFileAs($path, $file, $nome);
$arquivo = new Arquivo();
$arquivo->titulo = $request->nomePlanoTrabalho[$key]; $arquivo = new Arquivo();
$arquivo->nome = $path . $nome; $arquivo->titulo = $request->nomePlanoTrabalho[$key];
$arquivo->trabalhoId = $trabalho->id; $arquivo->nome = $path . $nome;
$arquivo->data = $mytime; $arquivo->trabalhoId = $trabalho->id;
$arquivo->participanteId = $participante->id; $arquivo->data = $mytime;
$arquivo->versaoFinal = true; $arquivo->participanteId = $participante->id;
$arquivo->save(); $arquivo->versaoFinal = true;
$arquivo->save();
}
} }
} }
......
...@@ -318,7 +318,7 @@ ...@@ -318,7 +318,7 @@
<div class="row"> <div class="row">
<div class="col-sm-4"> <div class="col-sm-4">
<label>Titulo* </label> <label>Titulo* </label>
<input type="text" style="margin-bottom:10px" class="form-control @error('nomePlanoTrabalho') is-invalid @enderror" name="nomePlanoTrabalho[]" placeholder="Nome" required value="{{old('nomePlanoTrabalho.'.$i)}}"> <input type="text" style="margin-bottom:10px" class="form-control @error('nomePlanoTrabalho') is-invalid @enderror" name="nomePlanoTrabalho[]" placeholder="Nome" value="{{old('nomePlanoTrabalho.'.$i)}}">
@error('nomePlanoTrabalho') @error('nomePlanoTrabalho')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block"> <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment