Commit 2593515b authored by Gabriel-31415's avatar Gabriel-31415
Browse files

ajuste em editar e visualizar trabalho de outra pessoa

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