diff --git a/app/Http/Controllers/ParticipanteController.php b/app/Http/Controllers/ParticipanteController.php index 82c993f7f56b3a4ed7c96a00c754747c71d4462f..aca64aa7d2398f62c05e7c3477be0928e2a52ddd 100644 --- a/app/Http/Controllers/ParticipanteController.php +++ b/app/Http/Controllers/ParticipanteController.php @@ -3,6 +3,9 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Evento; +use App\Trabalho; +use App\Participante; class ParticipanteController extends Controller { @@ -10,4 +13,16 @@ class ParticipanteController extends Controller return view('participante.index'); } + + public function edital($id){ + $edital = Evento::find($id); + $trabalhosId = Trabalho::where('evento_id', '=', $id)->select('id')->get(); + $meusTrabalhosId = Participante::where('user_id', '=', Auth()->user()->id) + ->whereIn('trabalho_id', $trabalhosId)->select('trabalho_id')->get(); + $projetos = Trabalho::whereIn('id', $meusTrabalhosId)->get(); + + //dd($projetos); + + return view('participante.projetos')->with(['edital' => $edital, 'projetos' => $projetos]); + } } diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index 18abebdd84e5c1dbf7e00ae504c2f9180662c97d..33003cac807e2acc3b53bfba95a2191a332b5283 100644 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -105,7 +105,9 @@ class TrabalhoController extends Controller 'nomePlanoTrabalho.*' => ['required', 'string'], 'anexoProjeto' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoCONSU' => ['required', 'file', 'mimes:pdf', 'max:2000000'], - 'anexoComiteEtica' => ['required', 'file', 'mimes:pdf', 'max:2000000'], + 'botao' => ['required'], + 'anexoComiteEtica' => ['required_without:justificativaAutorizacaoEtica', 'file', 'mimes:pdf', 'max:2000000'], + 'justificativaAutorizacaoEtica' => ['required_without:anexoComiteEtica', 'file', 'mimes:pdf', 'max:2000000'], 'anexoLatterCoordenador' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoPlanilha' => ['required', 'file', 'mimes:pdf', 'max:2000000'], 'anexoPlanoTrabalho.*' => ['required', 'file', 'mimes:pdf', 'max:2000000'], @@ -228,6 +230,7 @@ class TrabalhoController extends Controller Storage::putFileAs($path, $file, $nome); $arquivo = new Arquivo(); + $arquivo->titulo = $request->nomePlanoTrabalho[$key]; $arquivo->nome = $path . $nome; $arquivo->trabalhoId = $trabalho->id; $arquivo->data = $mytime; @@ -270,9 +273,30 @@ class TrabalhoController extends Controller * @param \App\Trabalho $trabalho * @return \Illuminate\Http\Response */ - public function show(Trabalho $trabalho) + public function show($id) { // + $projeto = Trabalho::find($id); + $edital = Evento::find($projeto->evento_id); + $grandeArea = GrandeArea::where('id', $projeto->grande_area_id)->select('nome')->first(); + $area = Area::where('id', $projeto->area_id)->select('nome')->first(); + $subarea = Subarea::where('id', $projeto->sub_area_id)->select('nome')->first(); + $proponente = Proponente::find($projeto->proponente_id); + $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.visualizar')->with(['projeto' => $projeto, + 'grandeArea' => $grandeArea, + 'area' => $area, + 'subArea' => $subarea, + 'proponente' => $proponente, + 'edital' => $edital, + 'users' => $users, + 'funcaoParticipantes' => $funcaoParticipantes, + 'participantes' => $participantes, + 'arquivos' => $arquivos,]); } /** @@ -439,6 +463,7 @@ class TrabalhoController extends Controller Storage::putFileAs($path, $file, $nome); $arquivo = new Arquivo(); + $arquivo->titulo = $request->nomePlanoTrabalho[$key]; $arquivo->nome = $path . $nome; $arquivo->trabalhoId = $trabalho->id; $arquivo->data = $mytime; @@ -471,6 +496,7 @@ class TrabalhoController extends Controller Storage::putFileAs($path, $file, $nome); $arquivo = new Arquivo(); + $arquivo->titulo = $request->nomePlanoTrabalho[$key]; $arquivo->nome = $path . $nome; $arquivo->trabalhoId = $trabalho->id; $arquivo->data = $mytime; @@ -513,6 +539,16 @@ class TrabalhoController extends Controller return redirect()->back(); } + public function excluirParticipante($id){ + $participante = Participante::where('user_id', Auth()->user()->id) + ->where('trabalho_id', $id)->first(); + + $participante->trabalhos()->detach($id); + $participante->delete(); + + return redirect()->back(); + } + public function novaVersao(Request $request){ $mytime = Carbon::now('America/Recife'); $mytime = $mytime->toDateString(); @@ -676,4 +712,9 @@ class TrabalhoController extends Controller $projeto = Trabalho::find($id); return Storage::download($projeto->anexoPlanilhaPontuacao); } + + public function baixarAnexoJustificativa($id) { + $projeto = Trabalho::find($id); + return Storage::download($projeto->justificativaAutorizacaoEtica); + } } diff --git a/app/Participante.php b/app/Participante.php index 5f07bef5ead99e86312685995378b4e4d06ef9a2..6fd42fdadabc4b1672f9a021365cd53e26a13c67 100644 --- a/app/Participante.php +++ b/app/Participante.php @@ -3,9 +3,12 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class Participante extends Model { + use SoftDeletes; + protected $fillable = ['name', 'user_id', 'trabalho_id', 'participante_id']; public function user(){ diff --git a/database/migrations/2020_02_05_123115_create_arquivos_table.php b/database/migrations/2020_02_05_123115_create_arquivos_table.php index 5d7119d472ac7acd49fec662a761717ef558324b..26e583ccb37356fd5e6d9af97fbbfc252f534680 100644 --- a/database/migrations/2020_02_05_123115_create_arquivos_table.php +++ b/database/migrations/2020_02_05_123115_create_arquivos_table.php @@ -17,6 +17,7 @@ class CreateArquivosTable extends Migration $table->bigIncrements('id'); $table->timestamps(); $table->string('nome'); + $table->string('titulo'); $table->integer('versao')->nullable(); $table->boolean('versaoFinal')->nullable(); $table->date('data')->nullable(); diff --git a/database/migrations/2020_05_21_020029_create_plano_trabalhos_table.php b/database/migrations/2020_05_21_020029_create_plano_trabalhos_table.php deleted file mode 100644 index 26e51d22894240fab1557fc426cd2b944bf12f50..0000000000000000000000000000000000000000 --- a/database/migrations/2020_05_21_020029_create_plano_trabalhos_table.php +++ /dev/null @@ -1,36 +0,0 @@ -bigIncrements('id'); - $table->string('titulo'); - $table->string('anexoPlanoTrabalho'); - $table->timestamps(); - - $table->unsignedBigInteger('trabalho_id'); - $table->foreign('trabalho_id')->references('id')->on('trabalhos'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('plano_trabalhos'); - } -} diff --git a/database/migrations/2020_05_23_054945_create_participantes_table.php b/database/migrations/2020_05_23_054945_create_participantes_table.php index 8b559d61dc6908c3ac8ec7d60a507967d98a0ee1..b944cc5724483c807065b3500707f6ee55633d37 100644 --- a/database/migrations/2020_05_23_054945_create_participantes_table.php +++ b/database/migrations/2020_05_23_054945_create_participantes_table.php @@ -25,6 +25,8 @@ class CreateParticipantesTable extends Migration $table->unsignedBigInteger('funcao_participante_id')->nullable(); $table->foreign('funcao_participante_id')->references('id')->on('funcao_participantes'); + + $table->softDeletes(); }); } diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 50441fb0b66d1167c2a89b26b0eebf2a06a95256..093006b1da49859c04a869657789dfe1edf96a6e 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -61,7 +61,7 @@ return [ 'required_unless' => 'O :attribute é necessário a menos que :other esteja em :values.', 'required_with' => 'O campo é obrigatório.', 'required_with_all' => 'O campo :attribute é obrigatório quando :values estão presentes.', - 'required_without' => 'O campo :attribute é obrigatório quando :values não está presente.', + 'required_without' => 'O campo é obrigatório.', 'required_without_all' => 'O campo :attribute é obrigatório quando nenhum destes estão presentes: :values.', 'same' => ':Attribute e :other devem ser iguais.', 'size' => [ diff --git a/resources/views/administrador/editais.blade.php b/resources/views/administrador/editais.blade.php index 89788ff2611def70738589d1a515c75a81dc87ca..68b2f48510ea65248ec8866bc7a292a2b6dd4d2f 100644 --- a/resources/views/administrador/editais.blade.php +++ b/resources/views/administrador/editais.blade.php @@ -167,8 +167,8 @@