Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
19cb5cc3
Commit
19cb5cc3
authored
Jun 16, 2020
by
alinetenorio
Browse files
armazenando anexos do projeto temporariamente
parent
737ab459
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/AnexosTemp.php
0 → 100644
View file @
19cb5cc3
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
class
AnexosTemp
extends
Model
{
//
}
app/Http/Controllers/TrabalhoController.php
View file @
19cb5cc3
...
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers
;
use
App\AnexosTemp
;
use
App\Trabalho
;
use
App\Coautor
;
use
App\Evento
;
...
...
@@ -22,6 +23,7 @@ use App\Avaliador;
use
Carbon\Carbon
;
use
Auth
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\File
;
use
Illuminate\Support\Facades\Storage
;
use
App\Mail\EmailParaUsuarioNaoCadastrado
;
use
Illuminate\Support\Facades\Mail
;
...
...
@@ -82,7 +84,10 @@ class TrabalhoController extends Controller
return
redirect
()
->
route
(
'home'
);
}
}
//--Salvando os anexos da submissão temporariamente
$this
->
armazenarAnexosTemp
(
$request
,
Auth
::
user
()
->
id
);
//O anexo de Decisão do CONSU dependo do tipo de edital
if
(
$evento
->
tipo
==
'PIBIC'
||
$evento
->
tipo
==
'PIBIC-EM'
){
...
...
@@ -99,12 +104,13 @@ class TrabalhoController extends Controller
'emailParticipante.*'
=>
[
'required'
,
'string'
],
'funcaoParticipante.*'
=>
[
'required'
,
'string'
],
'nomePlanoTrabalho.*'
=>
[
'required'
,
'string'
],
'anexoProjeto'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
//--Verificando se anexos já foram submetidos
'anexoProjeto'
=>
[(
$request
->
anexoProjetoPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoCONSU'
=>
[
'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'
],
'anexoLatte
r
Coordenador'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoLatte
s
Coordenador'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoPlanilha'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoPlanoTrabalho.*'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
]);
...
...
@@ -126,10 +132,10 @@ class TrabalhoController extends Controller
'proponente_id'
=>
$proponente
->
id
,
//Anexos
'anexoCONSU'
=>
$request
->
anexoCONSU
,
'anexoProjeto'
=>
$request
->
anexoProjeto
,
'anexoProjeto'
=>
$request
->
anexoProjeto
!=
null
?
$request
->
anexoProjeto
:
""
,
'anexoAutorizacaoComiteEtica'
=>
$request
->
anexoComiteEtica
,
'justificativaAutorizacaoEtica'
=>
$request
->
justificativaAutorizacaoEtica
,
'anexoLattesCoordenador'
=>
$request
->
anexoLatte
r
Coordenador
,
'anexoLattesCoordenador'
=>
$request
->
anexoLatte
s
Coordenador
,
'anexoPlanilhaPontuacao'
=>
$request
->
anexoPlanilha
,
]);
//dd($trabalho);
...
...
@@ -149,7 +155,7 @@ class TrabalhoController extends Controller
'funcaoParticipante.*'
=>
[
'required'
,
'string'
],
'nomePlanoTrabalho.*'
=>
[
'required'
,
'string'
],
'anexoProjeto'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoLatte
r
Coordenador'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoLatte
s
Coordenador'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoPlanilha'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoPlanoTrabalho.*'
=>
[
'required'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
]);
...
...
@@ -172,7 +178,7 @@ class TrabalhoController extends Controller
'anexoProjeto'
=>
$request
->
anexoProjeto
,
'anexoAutorizacaoComiteEtica'
=>
$request
->
anexoComiteEtica
,
'justificativaAutorizacaoEtica'
=>
$request
->
justificativaAutorizacaoEtica
,
'anexoLattesCoordenador'
=>
$request
->
anexoLatte
r
Coordenador
,
'anexoLattesCoordenador'
=>
$request
->
anexoLatte
s
Coordenador
,
'anexoPlanilhaPontuacao'
=>
$request
->
anexoPlanilha
,
]);
...
...
@@ -248,11 +254,21 @@ class TrabalhoController extends Controller
$trabalho
->
justificativaAutorizacaoEtica
=
Storage
::
putFileAs
(
$pasta
,
$request
->
justificativaAutorizacaoEtica
,
"Justificativa.pdf"
);
}
$trabalho
->
anexoProjeto
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoProjeto
,
"Projeto.pdf"
);
$trabalho
->
anexoLattesCoordenador
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoLatterCoordenador
,
"Latter_Coordenador.pdf"
);
if
(
!
isset
(
$request
->
anexoProjeto
)
&&
$request
->
anexoProjetoPreenchido
==
'sim'
){
$anexosTemp
=
AnexosTemp
::
where
(
'eventoId'
,
$request
->
editalId
)
->
where
(
'proponenteId'
,
Auth
::
user
()
->
id
)
->
orderByDesc
(
'updated_at'
)
->
first
();
Storage
::
move
(
$anexosTemp
->
anexoProjeto
,
$pasta
.
'/Projeto.pdf'
);
$trabalho
->
anexoProjeto
=
$pasta
.
'/Projeto.pdf'
;
}
else
{
$trabalho
->
anexoProjeto
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoProjeto
,
"Projeto.pdf"
);
}
$trabalho
->
anexoLattesCoordenador
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoLattesCoordenador
,
"Latter_Coordenador.pdf"
);
$trabalho
->
anexoPlanilhaPontuacao
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoPlanilha
,
"Planilha.pdf"
);
$trabalho
->
update
();
//Deletando arquivos temporários
Storage
::
deleteDirectory
(
'anexosTemp/'
.
$request
->
editalId
.
'/'
.
Auth
::
user
()
->
id
);
//dd($trabalho);
$subject
=
"Submissão de Trabalho"
;
...
...
@@ -263,6 +279,54 @@ class TrabalhoController extends Controller
return
redirect
()
->
route
(
'evento.visualizar'
,[
'id'
=>
$request
->
editalId
]);
}
//Armazena temporariamente anexos da submissão, no banco de dados e no storage
public
function
armazenarAnexosTemp
(
Request
$request
,
$proponenteId
){
//---Anexos do Projeto
$anexosTemp
=
AnexosTemp
::
where
(
'eventoId'
,
$request
->
editalId
)
->
where
(
'proponenteId'
,
$proponenteId
)
->
orderByDesc
(
'updated_at'
)
->
first
();
if
(
$anexosTemp
==
null
){
$anexosTemp
=
new
AnexosTemp
();
$jaExiste
=
false
;
}
else
{
$jaExiste
=
true
;
}
$pasta
=
'anexosTemp/'
.
$request
->
editalId
.
'/'
.
$proponenteId
;
if
(
!
(
is_null
(
$request
->
anexoCONSU
))
)
{
$anexosTemp
->
anexoDecisaoCONSU
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoCONSU
,
"CONSU.pdf"
);
}
if
(
!
(
is_null
(
$request
->
anexoComiteEtica
)))
{
$anexosTemp
->
anexoAutorizacaoComiteEtica
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoComiteEtica
,
"Comite_de_etica.pdf"
);
}
if
(
!
(
is_null
(
$request
->
justificativaAutorizacaoEtica
)))
{
$anexosTemp
->
justificativaAutorizacaoEtica
=
Storage
::
putFileAs
(
$pasta
,
$request
->
justificativaAutorizacaoEtica
,
"Justificativa.pdf"
);
}
if
(
!
(
is_null
(
$request
->
anexoProjeto
)))
{
$anexosTemp
->
anexoProjeto
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoProjeto
,
"Projeto.pdf"
);
}
if
(
!
(
is_null
(
$request
->
anexoLattesCoordenador
)))
{
$anexosTemp
->
anexoLattesCoordenador
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoLattesCoordenador
,
"Latter_Coordenador.pdf"
);
}
if
(
!
(
is_null
(
$request
->
anexoPlanilha
)))
{
$anexosTemp
->
anexoPlanilhaPontuacao
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoPlanilha
,
"Planilha.pdf"
);
}
$anexosTemp
->
eventoId
=
$request
->
editalId
;
$anexosTemp
->
proponenteId
=
$proponenteId
;
if
(
!
$jaExiste
){
$anexosTemp
->
save
();
}
else
{
$anexosTemp
->
update
();
}
//---Anexos planos de trabalho
}
/**
* Display the specified resource.
*
...
...
@@ -414,9 +478,9 @@ class TrabalhoController extends Controller
$trabalho
->
anexoAutorizacaoComiteEtica
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoComiteEtica
,
"Comite_de_etica.pdf"
);
}
if
(
!
(
is_null
(
$request
->
anexoLatte
r
Coordenador
)))
{
if
(
!
(
is_null
(
$request
->
anexoLatte
s
Coordenador
)))
{
Storage
::
delete
(
$trabalho
->
anexoLattesCoordenador
);
$trabalho
->
anexoLattesCoordenador
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoLatte
r
Coordenador
,
"Latter_Coordenador.pdf"
);
$trabalho
->
anexoLattesCoordenador
=
Storage
::
putFileAs
(
$pasta
,
$request
->
anexoLatte
s
Coordenador
,
"Latter_Coordenador.pdf"
);
}
if
(
!
(
is_null
(
$request
->
anexoPlanilha
)))
{
...
...
@@ -753,4 +817,13 @@ class TrabalhoController extends Controller
$projeto
=
Trabalho
::
find
(
$id
);
return
Storage
::
download
(
$projeto
->
justificativaAutorizacaoEtica
);
}
public
function
baixarAnexoTemp
(
$eventoId
,
$nomeAnexo
)
{
$proponenteId
=
Auth
::
user
()
->
id
;
$anexosTemp
=
AnexosTemp
::
where
(
'eventoId'
,
$eventoId
)
->
where
(
'proponenteId'
,
$proponenteId
)
->
orderByDesc
(
'updated_at'
)
->
first
();
return
Storage
::
download
(
$anexosTemp
->
$nomeAnexo
);
}
}
database/migrations/2020_06_15_160417_create_anexos_temps_table.php
0 → 100644
View file @
19cb5cc3
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateAnexosTempsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'anexos_temps'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
timestamps
();
$table
->
string
(
'anexoProjeto'
)
->
nullable
();
$table
->
string
(
'anexoDecisaoCONSU'
)
->
nullable
();
$table
->
string
(
'anexoPlanilhaPontuacao'
)
->
nullable
();
$table
->
string
(
'anexoLattesCoordenador'
)
->
nullable
();
$table
->
string
(
'anexoAutorizacaoComiteEtica'
)
->
nullable
();
$table
->
string
(
'justificativaAutorizacaoEtica'
)
->
nullable
();
$table
->
integer
(
'eventoId'
);
$table
->
integer
(
'proponenteId'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'anexos_temps'
);
}
}
resources/views/evento/submeterTrabalho.blade.php
View file @
19cb5cc3
...
...
@@ -132,11 +132,15 @@
{{-- Arquivo --}}
<div class="
col
-
sm
-
6
">
<label for="
anexoProjeto
" class="
col
-
form
-
label
">{{ __('Anexo Projeto*:') }}</label>
@if(old('anexoProjetoPreenchido') != null)
<a id="
anexoProjetoTemp
" href="
{{
route
(
'baixar.anexo.temp'
,
[
'eventoId'
=>
$edital
->
id
,
'nomeAnexo'
=>
'anexoProjeto'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoProjetoPreenchido
" name="
anexoProjetoPreenchido
" value="
{{
old
(
'anexoProjetoPreenchido'
)
}}
" >
<div class="
input
-
group
">
<div class="
custom
-
file
">
<input type="
file
" class="
custom
-
file
-
input
@
error
(
'anexoProjeto'
)
is
-
invalid
@
enderror
" id="
anexoProjeto
" aria-describedby="
inputGroupFileAddon01
" name="
anexoProjeto
"
>
<input type="
file
" class="
custom
-
file
-
input
@
error
(
'anexoProjeto'
)
is
-
invalid
@
enderror
" id="
anexoProjeto
" aria-describedby="
inputGroupFileAddon01
" name="
anexoProjeto
"
onchange="
exibirAnexoTemp
(
this
)
">
<label class="
custom
-
file
-
label
" id="
custom
-
file
-
label
" for="
anexoProjeto
">O arquivo deve ser no formato PDF de até 2mb.</label>
</div>
</div>
...
...
@@ -148,16 +152,16 @@
</div>
<div class="
col
-
sm
-
6
">
<label for="
anexoLatte
r
Coordenador
" class="
col
-
form
-
label
">{{ __('Anexo do Lattes do Coordenador*:') }}</label>
<label for="
anexoLatte
s
Coordenador
" class="
col
-
form
-
label
">{{ __('Anexo do Lattes do Coordenador*:') }}</label>
<div class="
input
-
group
">
<div class="
custom
-
file
">
<input type="
file
" class="
custom
-
file
-
input
@
error
(
'anexoLatte
r
Coordenador'
)
is
-
invalid
@
enderror
" id="
inputGroupFile01
" aria-describedby="
anexoLatte
r
Coordenador
" name="
anexoLatte
r
Coordenador
">
<input type="
file
" class="
custom
-
file
-
input
@
error
(
'anexoLatte
s
Coordenador'
)
is
-
invalid
@
enderror
" id="
inputGroupFile01
" aria-describedby="
anexoLatte
s
Coordenador
" name="
anexoLatte
s
Coordenador
">
<label class="
custom
-
file
-
label
" id="
custom
-
file
-
label
" for="
inputGroupFile01
">O arquivo deve ser no formato PDF de até 2mb.</label>
</div>
</div>
@error('anexoLatte
r
Coordenador')
@error('anexoLatte
s
Coordenador')
<span class="
invalid
-
feedback
" role="
alert
" style="
overflow
:
visible
;
display
:
block
">
<strong>{{
$message
}}</strong>
</span>
...
...
@@ -627,6 +631,13 @@
})
}
function
exibirAnexoTemp
(
file
){
console
.
log
(
file
.
id
);
if
(
file
.
id
===
"anexoProjeto"
){
var
anexoProjetoPreenchido
=
document
.
getElementById
(
'anexoProjetoPreenchido'
);
anexoProjetoPreenchido
.
value
=
"sim"
;
}
}
window
.
onload
=
areas
();
</
script
>
@
endsection
\ No newline at end of file
routes/web.php
View file @
19cb5cc3
...
...
@@ -120,6 +120,7 @@ Route::group(['middleware' => ['isTemp', 'auth', 'verified']], function(){
Route
::
get
(
'/baixar/anexo-lattes/{id}'
,
'TrabalhoController@baixarAnexoLattes'
)
->
name
(
'baixar.anexo.lattes'
);
Route
::
get
(
'/baixar/anexo-planilha/{id}'
,
'TrabalhoController@baixarAnexoPlanilha'
)
->
name
(
'baixar.anexo.planilha'
);
Route
::
get
(
'/baixar/plano-de-trabalho/{id}'
,
'ArquivoController@baixarPlano'
)
->
name
(
'baixar.plano'
);
Route
::
get
(
'/baixar/anexo-temp/{eventoId}/{nomeAnexo}'
,
'TrabalhoController@baixarAnexoTemp'
)
->
name
(
'baixar.anexo.temp'
);
});
Route
::
prefix
(
'usuarios'
)
->
name
(
'admin.'
)
->
group
(
function
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment