Unverified Commit 51940025 authored by Gabriel Antônio da Silva's avatar Gabriel Antônio da Silva Committed by GitHub
Browse files

Merge pull request #145 from Gabriel-31415/master

ajuste em editar e visualizar trabalho de outra pessoa
parents 62a11163 2593515b
......@@ -315,8 +315,11 @@ class TrabalhoController extends Controller
public function show($id)
{
//
$projeto = Trabalho::find($id);
$projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
if(!$projeto){
return back()->withErrors(['Proposta não encontrada!']);
}
$edital = Evento::find($projeto->evento_id);
$grandeAreas = GrandeArea::all();
$areas = Area::all();
......@@ -343,7 +346,10 @@ class TrabalhoController extends Controller
public function exportProjeto($id)
{
$projeto = Trabalho::find($id);
$projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
if(!$projeto){
return back()->withErrors(['Proposta não encontrada!']);
}
$edital = Evento::find($projeto->evento_id);
$grandeAreas = GrandeArea::all();
$areas = Area::all();
......@@ -365,7 +371,10 @@ class TrabalhoController extends Controller
public function edit($id)
{
$proponente = Proponente::where('user_id', Auth::user()->id)->first();
$projeto = Trabalho::find($id);
$projeto = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
if(!$projeto){
return back()->withErrors(['Proposta não encontrada!']);
}
$edital = Evento::find($projeto->evento_id);
$grandeAreas = GrandeArea::all();
$areas = Area::all();
......@@ -683,8 +692,7 @@ class TrabalhoController extends Controller
public function update(UpdateTrabalho $request, $id)
{
// dd($request->participante_id);
// dd( $request->all() );
try {
if (!$request->has('rascunho') ) {
$request->merge([
......@@ -699,10 +707,12 @@ class TrabalhoController extends Controller
$request->merge([
'coordenador_id' => $evento->coordenadorComissao->id
]);
$trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
DB::beginTransaction();
$trabalho = Auth::user()->proponentes->trabalhos()->where('id', $id)->first();
if(!$trabalho){
return back()->withErrors(['Proposta não encontrada']);
}
$pasta = 'trabalhos/' . $evento->id . '/' . $trabalho->id;
$trabalho = $this->armazenarAnexosFinais($request, $pasta, $trabalho, $evento);
$trabalho->save();
......
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