public function getUpdate($idAnnuity, $idCategory, $id) { $annuity = ORGAnnuities::find($idAnnuity); $category = ORGAnnuityCategories::find($idCategory); $args = array('payment' => ORGAssociateAnnuities::find($id), 'associates' => ORGAssociates::all(), 'category' => $category, 'route' => self::parseRoute($idAnnuity, $idCategory), 'parent' => self::parseParent($idAnnuity)); return View::make('backend.annuities.payments.edit')->with($args); }
public function inicialize() { // Obtiene datos del asociado $this->conta = ORGAssociates::find($this->id_associado); // Numer de pedido $this->num_ped = $this->conta->id_asociado . '-' . date('Ym'); // Nosso numero $this->nossoNumeroInicial = $this->conta->id_asociado . date('Ym'); // Valores boleto (direccion, sacados, lineas de categorias) $this->valoresBoleto(); // Valor del boleto $this->setValorBoleto(); $this->valor_boleto1 = $this->getValorBoletoFormateado(); // Define valores del boleto $this->boletoSettings(); // Obtengo el identificador $id = $this->getIdentificadorNossoNumero($this->nossoNumeroInicial); // Calculo fecha de vencimiento $this->setFechaVencimiento(); $this->fator_vencimento = $this->fator_venc($this->dataVencimiento); // Monta cógigo de barras sem o dígito verificador $this->boleto['codbarra_sem_dv'] = $this->boleto['num_banco'] . $this->boleto['moeda'] . $this->fator_vencimento . $this->boleto['valor_zeroesq'] . $this->boleto['fixo'] . $this->boleto['num_agencia_sem_digito_verificador'] . $this->nosso_numero . $this->boleto["iof"] . $this->boleto['carteira']; // Calcula DV $this->dv = $this->calculaDv(); // Monta o código de barras com o dígito verificador (dv) $this->boleto['codbarra_dv'] = substr($this->boleto['codbarra_sem_dv'], 0, 4) . $this->dv . substr($this->boleto['codbarra_sem_dv'], 4, 39); // *************** LINHA DIGITÁVEL $this->campo_livre = $this->boleto["fixo"] . $this->boleto['num_agencia_sem_digito_verificador'] . $this->boleto["carteira"] . $this->nosso_numero . $this->boleto["num_conta"]; // 1º campo // Composto pelo código de Banco, código da moeda, as cinco primeiras posições do campo livre e o dígito de auto conferência(DAC) deste campo $this->campo1 = $this->boleto['num_banco'] . $this->boleto['moeda'] . substr($this->campo_livre, 0, 5); $this->dac_campo1 = $this->calculo_dac1($this->campo1); // 2º campo // Composto pelas posições 6ª a 15ª do campo livre e o dígito verificador deste campo $this->campo2 = substr($this->campo_livre, 5, 3) . substr($this->nosso_numero, 0, 7); $this->dac_campo2 = $this->calculo_dac2($this->campo2); // 3º campo // Composto pelas posições 16ª a 25ª do campo livre e o dígito verificador deste campo deste campo $this->campo3 = substr($this->campo_livre, 15, 10); $this->dac_campo3 = $this->calculo_dac2(substr($this->campo_livre, 18, 6) . '0' . $this->boleto["carteira"]); // 4º campo // Composto pelo dígito verificador do código de barras, ou seja, a 5ª posição do código de barras $this->campo4 = $this->dv; // 5º campo // Composto pelo fator de vencimento com 4(quatro) caracteres e o valor do documento com 10(dez) caracteres, sem separadores e sem edição $vBoleto = str_replace(',', '', $this->valor_boleto1); $vBoleto = str_replace('.', '', $vBoleto); $this->campo5 = $this->fator_venc($this->dataVencimiento) . $this->zero_esquerda($vBoleto, 10); // LINHA DIGITÁVEL $this->linha_digitavel = substr($this->campo1, 0, 5) . "." . substr($this->campo1, 5, 5) . $this->dac_campo1 . " "; $this->linha_digitavel = $this->linha_digitavel . substr($this->campo2, 0, 3) . substr($this->nosso_numero, 0, 2) . "." . substr($this->nosso_numero, 2, 5) . $this->dac_campo2 . " "; $this->linha_digitavel = $this->linha_digitavel . substr($this->campo3, 3, 5) . "." . $this->numeroFinal . '0' . $this->boleto["carteira"] . $this->dac_campo3 . " "; $this->linha_digitavel = $this->linha_digitavel . $this->campo4 . " " . $this->campo5; // crea pdf //$this->printTcPdf(); }
public function postTrabalhoactualizacaoassociado() { $course = Input::get('course'); $usertype = Input::get('usertype'); $inscription = Inscriptions::find(Input::get('inscription')); $estado = ORGStates::where('id_estado', '=', Input::get('estado'))->take(1)->get(); $estado_empresa = ORGStates::where('id_estado', '=', Input::get('estado_empresa'))->take(1)->get(); $participant = ORGAssociates::find(Input::get('id')); $participant->nombre_completo = Input::get('nombre_completo') != null ? Input::get('nombre_completo') : $participant->nombre_completo; $participant->rg = Input::get('rg') != null ? Input::get('rg') : $participant->rg; $participant->razon_social = Input::get('razon_social') != null ? Input::get('razon_social') : $participant->razon_social; $participant->inscripcion_estadual = Input::get('inscription_estadual') != null ? Input::get('inscription_estadual') : $participant->inscripcion_estadual; $participant->inscripcion_municipal = Input::get('inscription_municipal') != null ? Input::get('inscription_municipal') : $participant->inscripcion_municipal; $participant->tipo_pessoa = Input::get('tipo_pessoa') != null ? Input::get('tipo_pessoa') : $participant->tipo_pessoa; $participant->cpf = Input::get('cpf') != null ? Input::get('cpf') : $participant->cpf; $participant->cnpj = Input::get('cnpj') != null ? Input::get('cnpj') : $participant->cnpj; $participant->passaporte = Input::get('passaporte') != null ? Input::get('passaporte') : $participant->passaporte; $participant->email = Input::get('email') != null ? Input::get('email') : $participant->email; $participant->web_site = Input::get('web_site') != null ? Input::get('web_site') : $participant->web_site; $participant->responsavel = Input::get('responsavel') != null ? Input::get('responsavel') : $participant->responsavel; $participant->observacao = Input::get('observacao') != null ? Input::get('observacao') : $participant->observacao; $participant->empresa = Input::get('empresa') != null ? Input::get('empresa') : $participant->empresa; $participant->cargo = Input::get('cargo') != null ? Input::get('cargo') : $participant->cargo; $participant->cep_res = Input::get('cep_res') != null ? Input::get('cep_res') : $participant->cep_res; $participant->cep_com = Input::get('cep_com') != null ? Input::get('cep_com') : $participant->cep_com; $participant->logradouro_res = Input::get('logradouro_res') != null ? Input::get('logradouro_res') : $participant->logradouro_res; $participant->logradouro_com = Input::get('logradouro_com') != null ? Input::get('logradouro_com') : $participant->logradouro_com; $participant->dir_res = Input::get('dir_res') != null ? Input::get('dir_res') : $participant->dir_res; $participant->dir_com = Input::get('dir_com') != null ? Input::get('dir_com') : $participant->dir_com; $participant->complemento_res = Input::get('complemento_res') != null ? Input::get('complemento_res') : $participant->complemento_res; $participant->complemento_com = Input::get('complemento_com') != null ? Input::get('complemento_com') : $participant->complemento_com; $participant->numero_res = Input::get('numero_res') != null ? Input::get('numero_res') : $participant->numero_res; $participant->numero_com = Input::get('numero_com') != null ? Input::get('numero_com') : $participant->numero_com; $participant->bairro_res = Input::get('bairro_res') != null ? Input::get('bairro_res') : $participant->bairro_res; $participant->bairro_com = Input::get('bairro_com') != null ? Input::get('bairro_com') : $participant->bairro_com; $participant->pais_res = Input::get('pais_res') != null ? Input::get('pais_res') : $participant->pais_res; $participant->pais_com = Input::get('pais_com') != null ? Input::get('pais_com') : $participant->pais_com; $participant->municipio_res = Input::get('municipio_res') != null ? Input::get('municipio_res') : $participant->municipio_res; $participant->municipio_com = Input::get('municipio_com') != null ? Input::get('municipio_com') : $participant->municipio_com; $participant->uf_res = Input::get('uf_res') != null ? Input::get('uf_res') : $participant->uf_res; $participant->uf_com = Input::get('uf_com') != null ? Input::get('uf_com') : $participant->uf_com; $participant->ddi_res = Input::get('ddi_res') != null ? Input::get('ddi_res') : $participant->ddi_res; $participant->ddi_com = Input::get('ddi_com') != null ? Input::get('ddi_com') : $participant->ddi_com; $participant->ddd_res = Input::get('ddd_res') != null ? Input::get('ddd_res') : $participant->ddd_res; $participant->ddd_com = Input::get('ddd_com') != null ? Input::get('ddd_com') : $participant->ddd_com; $participant->ddi_two_res = Input::get('ddi_two_res') != null ? Input::get('ddi_two_res') : $participant->ddi_two_res; $participant->ddi_two_com = Input::get('ddi_two_com') != null ? Input::get('ddi_two_com') : $participant->ddi_two_com; $participant->ddd_two_res = Input::get('ddd_two_res') != null ? Input::get('ddd_two_res') : $participant->ddd_two_res; $participant->ddd_two_com = Input::get('ddd_two_com') != null ? Input::get('ddd_two_com') : $participant->ddd_two_com; $participant->ddi_cel_res = Input::get('ddi_cel_res') != null ? Input::get('ddi_cel_res') : $participant->ddi_cel_res; $participant->ddi_cel_com = Input::get('ddi_cel_com') != null ? Input::get('ddi_cel_com') : $participant->ddi_cel_com; $participant->telefone_res = Input::get('telefone_res') != null ? Input::get('telefone_res') : $participant->telefone_res; $participant->telefone_com = Input::get('telefone_com') != null ? Input::get('telefone_com') : $participant->telefone_com; $participant->telefone_seg_res = Input::get('telefone_seg_res') != null ? Input::get('telefone_seg_res') : $participant->telefone_seg_res; $participant->telefone_seg_com = Input::get('telefone_seg_com') != null ? Input::get('telefone_seg_com') : $participant->telefone_seg_com; $participant->ddd_cel_res = Input::get('ddd_cel_res') != null ? Input::get('ddd_cel_res') : $participant->ddd_cel_res; $participant->ddd_cel_com = Input::get('ddd_cel_com') != null ? Input::get('ddd_cel_com') : $participant->ddd_cel_com; $participant->celular_res = Input::get('celular_res') != null ? Input::get('celular_res') : $participant->celular_res; $participant->celular_com = Input::get('celular_com') != null ? Input::get('celular_com') : $participant->celular_com; $participant->save(); Auth::user()->login($participant->associate->getuser); $array = array('msg_success' => Lang::get('messages.login_welcome'), 'usertype' => $usertype, 'inscription' => $inscription); return Redirect::to($inscription->course->route . '/arquivos')->with($array); }
public function getUpdate($idAssociate, $id) { $args = array('payment' => ORGAssociateAnnuities::find($id), 'associate' => ORGAssociates::find($idAssociate), 'route' => self::parseRoute($idAssociate), 'parent' => self::$parent); return View::make('backend.clients.associates.payments.update')->with($args); }
public function postAddassociate($idCourse) { // dd(Input::get('usertype')); $course = Courses::find($idCourse); $usertype = UserTypes::find(Input::get('usertype')); $associate = ORGAssociates::find(Input::get('associado')); // dd($usertype); if ($associate->associate == null) { $user = new User(); $user->name = $associate->nombre_completo; $user->email = $associate->email; $user->type = 'associate'; $user->save(); $new_associate = new Associates(); $new_associate->associate = $associate->id_asociado; $new_associate->user = $user->id; $new_associate->name = $associate->nombre_completo; $new_associate->email = $associate->email; $new_associate->password = $associate->senha; $new_associate->cpf = $associate->cpf; $new_associate->type = 'associate'; $new_associate->save(); $inscription = new Inscriptions(); $inscription->id_course = $course->id; $inscription->id_user = $user->id; $inscription->id_usertype = $usertype->id; $inscription->save(); } else { $this_associate = $associate->associate; if ($this_associate->user == null) { $user = new User(); $user->name = $associate->nombre_completo; $user->email = $associate->email; $user->type = 'associate'; $user->save(); $this_associate->user = $user->id; $this_associate->save(); } $inscription = new Inscriptions(); $inscription->id_course = $course->id; $inscription->id_user = $this_associate->user; $inscription->id_usertype = $usertype->id; $inscription->save(); } return Redirect::to(self::parseRoute($idCourse)); }
public function postCadastrojuridica() { if (count(ORGAssociates::where('email', '=', Input::get('login'))->get()) > 0) { return Redirect::to(self::$route . '/cadastrojuridica')->with(array('msg_error' => 'Email Cadastrado')); } elseif (count(User::where('email', '=', Input::get('login'))->get()) > 0) { return Redirect::to(self::$route . '/cadastrojuridica')->with(array('msg_error' => 'Email Cadastrado')); } else { $org_associate = new ORGAssociates(); $org_associate->email = Input::get('login'); $org_associate->senha = md5(Input::get('password')); $org_associate->tipo_pessoa = 'J'; $org_associate->save(); $user = new User(); $user->email = Input::get('login'); $user->password = Hash::make(Input::get('password')); $user->type = 'associate'; $user->status = 'publish'; $user->save(); $associate = new Associates(); $associate->email = Input::get('login'); $associate->password = md5(Input::get('password')); $associate->user = $user->id; $associate->associate = $org_associate->id_asociado; $associate->type = 'associate'; $associate->status = 'publish'; $associate->save(); Auth::user()->login($user); return Redirect::to(self::$route); } }
public function postCadastro() { $associate = Auth::user()->user()->associate->asociado; if (Input::get('senha') != '') { $associate->senha = md5(Input::get('senha')); $assoc = $associate->associate; $assoc->password = $associate->senha; $assoc->save(); $user = $assoc->user; $user->password = Hash::make(Input::get('senha')); $user->save(); } if (Input::get('email') != $associate->email) { $new_email = Input::get('email'); $asocs = ORGAssociates::where('email', '=', $new_email)->get(); $users = User::where('email', '=', $new_email)->get(); $bool = false; if (isset($asocs[0])) { foreach ($asocs as $ascoc) { if ($ascoc->id_asociado != $associate->id_asociado) { $bool = true; } } } if (isset($users[0])) { foreach ($users as $user) { if (!($user->type == 'associate' and $user->associate->asociado->id_asociado == $associate->id_asociado)) { $bool = true; } } } if (!$bool) { $user = $associate->associate->getuser; $user->email = $new_email; $user->save(); } else { dd('Este correo ya le pertenece a un usuario registrado'); } } $associate->nombre_completo = Input::get('nombre_completo'); $associate->data_nascimento = date('Y-m-d', strtotime(Input::get('data_nascimento'))); $associate->email = Input::get('email'); $associate->sexo = Input::get('sexo'); $associate->edo_civil = Input::get('edo_civil'); $associate->senha = Input::get('senha') != '' ? md5(Input::get('senha')) : $associate->senha; $associate->passaporte = Input::get('passaporte'); $associate->web_site = Input::get('web_site'); $associate->institucion = Input::get('institucion'); $associate->categoria = Input::get('categoria'); $associate->empresa = Input::get('empresa'); $associate->cargo = Input::get('cargo'); $associate->rg = Input::get('rg'); $associate->cpf = Input::get('cpf'); $associate->tipo_correspondencia = Input::get('tipo_correspondencia'); $associate->cep_res = Input::get('cep_res'); $associate->logradouro_res = Input::get('logradouro_res'); $associate->numero_res = Input::get('numero_res'); $associate->dir_res = Input::get('dir_res'); $associate->complemento_res = Input::get('complemento_res'); $associate->bairro_res = Input::get('bairro_res'); $associate->pais_res = Input::get('pais_res'); $associate->uf_res = Input::get('uf_res'); $associate->municipio_res = Input::get('municipio_res'); $associate->cep_com = Input::get('cep_com'); $associate->logradouro_com = Input::get('logradouro_com'); $associate->numero_com = Input::get('numero_com'); $associate->dir_com = Input::get('dir_com'); $associate->complemento_com = Input::get('complemento_com'); $associate->bairro_com = Input::get('bairro_com'); $associate->pais_com = Input::get('pais_com'); $associate->uf_com = Input::get('uf_com'); $associate->municipio_com = Input::get('municipio_com'); $associate->area_de_especializacion = Input::get('area_de_especializacion'); $associate->classificados_conteudo = Input::get('classificados_conteudo'); $image = Input::file('classificados_imagem'); $validator = Validator::make(array('image' => $image), array('image' => 'required|mimes:png,jpeg,gif'), array('mimes' => 'Tipo de imagen inválido, solo se admite los formatos PNG, JPEG, y GIF')); if (!$validator->fails()) { $associate->classificados_imagem = $this->uploadImage($image); } $associate->save(); return Redirect::to(self::$route . '/cadastro'); }
public function engine($quest, $primary_key, $area) { $name_results = $this->nombre($quest, $primary_key, $area); $email_results = $this->email($quest, $primary_key, $area); $conteudo_results = $this->conteudo($quest, $primary_key, $area); $top_results = $this->arrayMergin($name_results, $email_results); $top_results = $this->arrayMergin($top_results, $conteudo_results); $pieces = strtolower(trim($quest)); $pieces = $this->explodePieces($pieces); //Contruyendo Expresion regular a partir de las palabras de la busqueda $regexp = $this->arrayToText($pieces, '|'); //Campo al cual se le hara la busqueda $field = 'classificados_conteudo'; //Busqueda de coincidencias en el Modelo por expresion regular $results = ORGAssociates::whereNested(function ($query) use($field, $regexp, $area) { $query->whereRaw($field . ' REGEXP "(' . $regexp . ')"'); $query->where('classificados_view', '=', '1'); if ($area != null && $area != '-1') { $query->where('area_de_especializacion', '=', $area); } })->select(array('id_asociado', 'classificados_conteudo'))->get(); //Inicializacion de pesos e ids $weights = array(); $ids = array(); //Llenando estructura de pesos foreach ($results as $result) { $coincidences = 0; $coincidences += count($this->multiexplode($pieces, $result->{$field})); $weights[] = $coincidences; $ids[] = $result->{$primary_key}; } //Ordenando arreglos por peso array_multisort($weights, SORT_DESC, $ids); $list = $this->arrayMergin($top_results, $ids); $ins = $this->arrayToText($list, ','); if ($ins == '') { $ins = '0'; } return array('pieces' => $pieces, 'regexp' => $regexp, 'ins' => $ins, 'primary_key' => $primary_key); //Busqueda de registros ordenados por pesos /*$results = ORGAssociates::whereNested(function($query) use($pieces, $regexp, $ins, $primary_key){ $query->whereRaw($primary_key.' in ('.$ins.') '); })->select(array('id_asociado','nombre_completo','email', 'telefone_res','ddi_res','sexo','classificados_conteudo','classificados_imagem')) ->orderByRaw(\DB::raw("FIELD(".$primary_key.", ".$ins.")"))->paginate(2); foreach( $results as $result ): $result->nombre_completo = str_replace($quest, ' <span style="background-color:#FFFF00">'.trim($quest).'</span> ', $result->nombre_completo); $result->email = str_replace($quest, ' <span style="background-color:#FFFF00">'.trim($quest).'</span> ', $result->email); $result->classificados_conteudo = str_replace($quest, ' <span style="background-color:#FFFF00">'.trim($quest).'</span> ', $result->classificados_conteudo); $result->classificados_conteudo = str_replace(mb_strtoupper($quest, 'UTF-8'), ' <span style="background-color:#FFFF00">'.trim(mb_strtoupper($quest, 'UTF-8')).'</span> ', $result->classificados_conteudo); $result->classificados_conteudo = str_replace(mb_strtolower($quest, 'UTF-8'), ' <span style="background-color:#FFFF00">'.trim(mb_strtolower($quest, 'UTF-8')).'</span> ', $result->classificados_conteudo); $result->classificados_conteudo= str_replace(mb_convert_case($quest, MB_CASE_TITLE, 'UTF-8'), ' <span style="background-color:#FFFF00">'.trim(mb_convert_case($quest, MB_CASE_TITLE, 'UTF-8')).'</span> ', $result->classificados_conteudo); foreach( $pieces as $piece ): $result->classificados_conteudo= str_replace($piece, ' <span style="background-color:#FFFF00">'.trim($piece).'</span> ', $result->classificados_conteudo); $result->classificados_conteudo= str_replace(mb_strtoupper($piece,'UTF-8'), ' <span style="background-color:#FFFF00">'.trim(mb_strtoupper($piece,'UTF-8')).'</span> ', $result->classificados_conteudo); $result->classificados_conteudo= str_replace(mb_strtolower($piece,'UTF-8'), ' <span style="background-color:#FFFF00">'.trim(mb_strtolower($piece,'UTF-8')).'</span> ', $result->classificados_conteudo); $result->classificados_conteudo= str_replace(mb_convert_case($piece, MB_CASE_TITLE, 'UTF-8'), ' <span style="background-color:#FFFF00">'.trim(mb_convert_case($piece, MB_CASE_TITLE, 'UTF-8')).'</span> ', $result->classificados_conteudo); //var_dump($result->classificados_conteudo); //var_dump('<br>'); //var_dump($piece); //var_dump('<br>'); //var_dump(strtoupper($piece)); //var_dump('<br>'); //var_dump(mb_strtoupper($piece,'UTF-8')); //var_dump('<br>'); //var_dump(utf8_encode($piece)); //var_dump('<br>'); //var_dump(utf8_decode($piece)); //var_dump('<br>'); //var_dump('<br>'); endforeach; endforeach; //Parametros para la vista $args = array( 'results' => $results, 'weights' => $weights, 'list' => $list ); //Construccion de vista con parametros ordenados return $results;*/ }
public function getStatus($id = '') { if ($id == '') { return Redirect::to($this->route)->with('msg_error', Lang::get('messages.associates_display_err')); } else { $associate = ORGAssociates::find($id); if ($associate->status_asso == 1) { $associate->status_asso = 0; } else { $associate->status_asso = 1; } $associate->save(); return Redirect::to($this->route)->with('msg_success', Lang::get('messages.associates_delete', array('title' => $associate->title))); } }
public function postAuth() { $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'), 'type' => 'associate'); $course = Courses::find(Input::get('course')); if (Auth::user()->attempt($credentials)) { if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) { return Redirect::to(self::$route . '/acusado'); } else { return Redirect::to(self::$route . '/pagamento'); } } else { $associate = Associates::getByEmail($credentials['email']); if (!empty($associate[0])) { $associate = $associate[0]; if ($associate->password == md5($credentials['password'])) { $user_finded = User::where('email', '=', $credentials['email'])->take(1)->get(); $user = null; if (!empty($user_finded[0])) { $user = $user_finded[0]; $user->password = Hash::make($credentials['password']); $user->save(); } else { $user = new User(); $user->email = $associate->email; if ($associate->nombre_completo != null) { $user->name = $associate->nombre_completo; } else { $user->name = "User without name"; } $user->status = 'publish'; $user->type = 'associate'; $user->password = Hash::make($credentials['password']); $user->save(); $associate->user = $user->id; $associate->save(); } Auth::user()->login($user); if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) { return Redirect::to(self::$route . '/acusado'); } else { return Redirect::to(self::$route . '/pagamento'); } } else { $associate = ORGAssociates::getByEmail($credentials['email']); if (!empty($associate[0])) { $associate = $associate[0]; if ($associate->senha == md5($credentials['password'])) { $user = new User(); $user->email = $associate->email; if ($associate->nombre_completo != null) { $user->name = $associate->nombre_completo; } else { $user->name = "User without name"; } $user->status = 'publish'; $user->type = 'associate'; $user->password = Hash::make($credentials['password']); $user->save(); $assoc = new Associates(); $assoc->associate = $associate->id_asociado; $assoc->user = $user->id; $assoc->email = $associate->email; if ($associate->nombre_completo != null) { $assoc->name = $associate->nombre_completo; } else { $assoc->name = "User without name"; } $assoc->cpf = $associate->cpf; $assoc->password = $associate->senha; $assoc->status = 'publish'; $assoc->type = 'associate'; $assoc->save(); Auth::user()->login($user); if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) { return Redirect::to(self::$route . '/acusado'); } else { return Redirect::to(self::$route . '/pagamento'); } } else { return Redirec::to(self::$route . '/error'); } } else { return Redirec::to(self::$route . '/error'); } return Redirec::to(self::$route . '/error'); } } else { $associate = ORGAssociates::getByEmail($credentials['email']); if (!empty($associate[0])) { $associate = $associate[0]; if ($associate->senha == md5($credentials['password'])) { $user = new User(); $user->email = $associate->email; if ($associate->nombre_completo != null) { $user->name = $associate->nombre_completo; } else { $user->name = "User without name"; } $user->status = 'publish'; $user->type = 'associate'; $user->password = Hash::make($credentials['password']); $user->save(); $assoc = new Associates(); $assoc->associate = $associate->id_asociado; $assoc->user = $user->id; $assoc->email = $associate->email; if ($associate->nombre_completo != null) { $assoc->name = $associate->nombre_completo; } else { $assoc->name = "User without name"; } $assoc->cpf = $associate->cpf; $assoc->password = $associate->senha; $assoc->status = 'publish'; $assoc->type = 'associate'; $assoc->save(); Auth::user()->login($user); if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) { return Redirect::to(self::$route . '/acusado'); } else { return Redirect::to(self::$route . '/pagamento'); } } else { return Redirec::to(self::$route . '/error'); } } else { return Redirec::to(self::$route . '/error'); } } } }