public function postPaisByContinente(Request $request) { if ($request->ajax()) { return Pais::where('continente', $request->get('idBuscar'))->orderBy('nombre')->get()->toJson(); } else { return "no ajax"; } }
/** * * @return a list of objects. */ public static function listByFullName($pais_id = '') { if ($pais_id != '') { $items = Pais::where('id', $pais_id)->get(); } else { $items = Pais::get(); } $key = 'id'; $value = 'full_name'; return Pais::getListFields($items, $key, $value); }
public function getCreateOrEdit(Guard $auth) { $postulante = Postulante::with('ciudadR.paisR')->where('user_id', $auth->id())->first(); $continentes = Continente::lists('nombre', 'id')->all(); //dd($postulante->toArray()); $documentoIdentidad = 0; $status = 0; $paises = array(null => 'Seleccione un país'); $ciudades = array(null => 'seleccione una ciudad'); if ($postulante) { $paises = Pais::where('continente', $postulante->ciudadR->paisR->continente)->orderBy('nombre')->lists('nombre', 'id')->all(); $ciudades = Ciudad::where('pais', $postulante->ciudadR->paisR->id)->orderBy('nombre')->lists('nombre', 'id')->all(); $status = 1; $postulante->documentoIdentidades; $parametros = array('id_postulante' => $postulante->id, 'pais' => $postulante->ciudadR->paisR->id, "tipo" => $postulante->documentoIdentidadR->first()->tipo, 'numero' => $postulante->documentoIdentidadR->first()->numero, 'continente' => $postulante->ciudadR->paisR->continente); if ($postulante->tipo_estudio === 'Pregrado') { $postulante->pregradosR; $parametros['procedencia'] = $postulante->pregradosR->procedencia; //verificar si el postulante es de la UACh o no. if ($postulante->pregradosR->procedencia === 'UACH') { $postulante->pregradosR->preUachsR; $parametros['email_institucional'] = $postulante->pregradosR->preUachsR->email_institucional; $parametros['grupo_sanguineo'] = $postulante->pregradosR->preUachsR->grupo_sanguineo; $parametros['enfermedades'] = $postulante->pregradosR->preUachsR->enfermedades; $parametros['telefono_2'] = $postulante->pregradosR->preUachsR->telefono; $parametros['direccion_2'] = $postulante->pregradosR->preUachsR->direccion; $parametros['ciudad_2'] = $postulante->pregradosR->preUachsR->ciudad; } } else { $postulante->postgradosR; $parametros['procedencia'] = $postulante->postgradosR->procedencia; $parametros['titulo_profesional'] = $postulante->postgradosR->titulo_profesional; //en contrucción } $postulante = array_merge($postulante->toArray(), $parametros); return view('postulacion.datos_personales.edit', compact('postulante', 'continentes', 'paises', 'ciudades')); } else { return view('postulacion.datos_personales.create', compact('continentes', 'paises', 'ciudades')); } }
public function recursiva_universidad($table, $id, $nombre) { $temp = array(); switch ($table) { case 'continente': $breadCrum = "Continente"; $temp = Continente::all(); $table = 'pais'; # code... break; case 'pais': $breadCrum = "País"; $temp = Pais::where('continente', $id)->get(); $table = 'Convenio'; # code... break; case 'Convenio': $breadCrum = "Convenio"; $temp = Collection::make([["nombre" => "Si"], ["nombre" => "No"]]); $table = 'Universidad'; # code... break; case 'Universidad': $breadCrum = "Universidad"; $temp = Universidad::where('pais', $id)->where('convenio', $nombre)->get(); $table = 'fin'; # code... break; } $arrayFinal = []; // $temp = Pais::all(); foreach ($temp as $key => $valor) { switch ($table) { case 'Universidad': $nombre = $temp->toArray()[$key]["nombre"]; # code... $padre = $id; $children = Universidad::where('pais', $padre)->where('convenio', $nombre)->count(); break; case 'fin': $padre = $valor->id; $nombre = $valor->nombre; $children = 1; break; default: # code... $padre = $valor->id; $nombre = $valor->nombre; $children = $valor->childrenUniversidad; break; } if ($children) { $arrayFinal[] = array('name' => $nombre, 'breadCrum' => $breadCrum, 'size' => $children, 'children' => $this->recursiva_universidad($table, $padre, $nombre)); } } return $arrayFinal; }
/** * Aditional functions **/ public static function showByNombre($nombre) { return Pais::where('nombre_pais', $nombre)->first(); }
/** * Define un atributo virtual. * * @return integer */ public function getNacionalidadAttribute() { $nacionalidad = ''; $pais = Pais::where('id', $this->nacionalidad_id)->first(); if ($pais) { $nacionalidad = $pais->nombre; } return $nacionalidad; }