예제 #1
0
 /**
  * Remove o Perfil se o Perfil ja for voluntario na Vaga de $vagaId,
  * @param  [type] $id      [description]
  * @param  [type] $vagaId [description]
  */
 public function getUnvoluntariarse($vagaId)
 {
     $User = Auth::user();
     $Candidato = $User->perfil;
     $vaga = Vaga::findOrFail($vagaId);
     //Se ja for voluntario, unsubscribe
     if ($vaga->voluntarios->find($Candidato->id)) {
         $vaga->voluntarios()->detach($Candidato->id);
         $vaga->push();
     }
     $voluntarios = $vaga->voluntarios;
     return view('vaga.show', compact('vaga', 'voluntarios', 'Candidato'));
 }