function nombreSolicitante() { $nombre = ""; if ($this->tipo_solicitante == 1) { $alumno = Alumno::find($this->cve_solicitante); $nombre = $alumno->nombreCompleto(); } else { if ($this->tipo_solicitante == 0) { $profesor = Profesor::find($this->cve_solicitante); $nombre = $profesor->nombreCompleto(); } } return $nombre; }
function dameNombre(Request $r) { $clave = $r->input('clave_alumno'); $res = ['success' => false]; try { $alumno = Alumno::find($clave); $res['nombre'] = ""; if ($alumno != null) { $res['nombre'] = $alumno->nombreCompleto(); $res['success'] = true; } } catch (Exception $e) { $res['msj'] = $e->getMessage(); } return response()->json($res); }
/** * Finds the Alumno model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Alumno the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Alumno::find()->where(['alumno.id' => $id])->joinWith('perfil')->one()) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function deleteDestroy($id) { $alumno = Alumno::find($id); //Alumno::destroy($id); //$alumno->restore(); //$queries = DB::getQueryLog(); //$last_query = end($queries); //return $last_query; if ($alumno) { $alumno->delete(); } else { return abort(400, 'Alumno no existe o está en Papelera.'); } return $alumno; }
public function search($params) { $query = Alumno::find()->joinWith('perfil')->joinWith('perfil.sexo')->joinWith('perfil.tipoDocumento'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes = array_merge($dataProvider->getSort()->attributes, ['perfilApellido' => ['asc' => ['perfil.apellido' => SORT_ASC], 'desc' => ['perfil.apellido' => SORT_DESC], 'label' => Yii::t('app', 'Apellido')], 'perfilNombre' => ['asc' => ['perfil.nombre' => SORT_ASC], 'desc' => ['perfil.nombre' => SORT_DESC], 'label' => Yii::t('app', 'Nombre')], 'tipoDocumentoAbreviatura' => ['asc' => ['tipo_documento.abreviatura' => SORT_ASC], 'desc' => ['tipo_documento.abreviatura' => SORT_DESC], 'label' => Yii::t('app', 'Tipo de Documento')], 'perfilNumeroDocumento' => ['asc' => ['perfil.numero_documento' => SORT_ASC], 'desc' => ['perfil.numero_documento' => SORT_DESC], 'label' => Yii::t('app', 'Documento')], 'sexoDescripcion' => ['asc' => ['sexo.descripcion' => SORT_ASC], 'desc' => ['sexo.descripcion' => SORT_DESC], 'label' => Yii::t('app', 'Sexo')], 'perfilTelefono' => ['asc' => ['perfil.telefono' => SORT_ASC], 'desc' => ['perfil.telefono' => SORT_DESC], 'label' => Yii::t('app', 'Teléfono')], 'perfilEmail' => ['asc' => ['perfil.email' => SORT_ASC], 'desc' => ['perfil.email' => SORT_DESC], 'label' => Yii::t('app', 'Email')]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'perfil.apellido', $this->perfilApellido])->andFilterWhere(['like', 'perfil.nombre', $this->perfilNombre])->andFilterWhere(['like', 'tipo_documento.abreviatura', $this->tipoDocumentoAbreviatura])->andFilterWhere(['like', 'perfil.numero_documento', $this->perfilNumeroDocumento])->andFilterWhere(['like', 'perfil.tipo_documento.abreviatura', $this->tipoDocumentoAbreviatura])->andFilterWhere(['like', 'perfil.email', $this->perfilEmail]); return $dataProvider; }