public function postTrabalhocadastro()
 {
     $course = Courses::find(Input::get('course'));
     $usertype = UserTypes::find(Input::get('usertype'));
     $estado = ORGStates::where('id_estado', '=', Input::get('estado'))->take(1)->get();
     $estado_empresa = ORGStates::where('id_estado', '=', Input::get('estado_empresa'))->take(1)->get();
     //dd(Input::all());
     $participant = new ORGParticipants();
     $participant->nome = Input::get('nome') != null ? Input::get('nome') : '';
     $participant->rg = Input::get('rg') != null ? Input::get('rg') : '';
     $participant->cpf = Input::get('cpf') != null ? Input::get('cpf') : '';
     $participant->endereco = Input::get('endereco') != null ? Input::get('endereco') : '';
     $participant->numero = Input::get('numero') != null ? Input::get('numero') : '';
     $participant->complemento = Input::get('complemento') != null ? Input::get('complemento') : '';
     $participant->cep = Input::get('cep') != null ? Input::get('cep') : '';
     $participant->cidade = Input::get('cidade') != null ? Input::get('cidade') : '';
     $participant->estado = isset($estado[0]->name_estado) ? $estado[0]->name_estado : '';
     /*$participant->empresa = Input::get('empresa') != null ? Input::get('empresa') : '';
     		$participant->cnpj = Input::get('cnpj_empresa') != null ? Input::get('cnpj_empresa') : '';
     		$participant->endereco_empresa = Input::get('endereco_empresa') != null ? Input::get('endereco_empresa') : '';
     		$participant->numero_empresa = Input::get('nome') != null ? Input::get('nome') : '';
     		$participant->complemento_empresa = Input::get('complemento_empresa') != null ? Input::get('complemento_empresa') : '';
     		$participant->cep_empresa = Input::get('cep_empresa') != null ? Input::get('cep_empresa') : '';
     		$participant->cidade_empresa = Input::get('cidade_empresa') != null ? Input::get('cidade_empresa') : '';
     		$participant->estado_empresa = isset($estado_empresa[0]->name_estado) ? $estado_empresa[0]->name_estado : '';
     		$participant->celular = Input::get('celular_empresa') != null ? Input::get('celular_empresa') : '';*/
     $participant->telefone = Input::get('telefone_empresa') != null ? Input::get('telefone_empresa') : '';
     $participant->email = Input::get('email') != null ? Input::get('email') : '';
     $participant->save();
     $user = new User();
     $user->email = $participant->email;
     if ($participant->nome != null) {
         $user->name = $participant->nome;
     } else {
         $user->name = "User without name";
     }
     $user->status = 'publish';
     $user->type = 'participant';
     $user->save();
     $participant = ORGParticipants::getByCPF($participant->cpf);
     $part = new Participants();
     $part->participant = $participant[0]->id_participante;
     $part->user = $user->id;
     $part->email = $participant[0]->email;
     $part->name = $participant[0]->nome;
     $part->cpf = $participant[0]->cpf;
     $part->status = 'publish';
     $part->type = 'participant';
     $part->save();
     Auth::user()->login($user);
     if ($inscription = Inscriptions::hasInscription(Auth::user()->user()->id, $course->id)) {
         $array = array('msg_success' => Lang::get('messages.login_welcome'), 'usertype' => $usertype, 'inscription' => $inscription);
         return Redirect::to($course->route . '/arquivos')->with($array);
     } else {
         $inscription = new Inscriptions();
         $inscription->id_course = $course->id;
         $inscription->id_user = Auth::user()->user()->id;
         $inscription->id_usertype = $usertype->id;
         $inscription->save();
         $array = array('usertype' => $usertype, 'inscription' => $inscription);
         return Redirect::to($course->route . '/arquivos')->with($array);
     }
 }
 public function postAddparticipant($idCourse)
 {
     $course = Courses::find($idCourse);
     $usertype = UserTypes::find(Input::get('usertype'));
     $participant = ORGParticipants::find(Input::get('participante'));
     if ($participant->participant == null) {
         $user = new User();
         $user->name = $participant->nome;
         $user->email = $participant->email;
         $user->type = 'participant';
         $user->save();
         $new_participant = new Participants();
         $new_participant->participant = $participant->id_participante;
         $new_participant->user = $user->id;
         $new_participant->name = $participant->nome;
         $new_participant->email = $participant->email;
         $new_participant->cpf = $participant->cpf;
         $new_participant->type = 'participant';
         $new_participant->status = 'publish';
         $new_participant->save();
         $inscription = new Inscriptions();
         $inscription->id_course = $course->id;
         $inscription->id_user = $user->id;
         $inscription->id_usertype = $usertype->id;
         $inscription->save();
     } else {
         $this_participant = $participant->participant;
         if ($this_participant->user == null) {
             $user = new User();
             $user->name = $participant->nome;
             $user->email = $participant->email;
             $user->type = 'participant';
             $user->save();
             $this_participant->user = $user->id;
             $this_participant->save();
         }
         $inscription = new Inscriptions();
         $inscription->id_course = $course->id;
         $inscription->id_user = $this_participant->user;
         $inscription->id_usertype = $usertype->id;
         $inscription->save();
     }
     return Redirect::to(self::parseRoute($idCourse));
 }