public function destroy($id)
 {
     $carreras = Carrera::find($id);
     $carreras->delete();
     Session::flash('message', 'La ' . $carreras->nombre . ' fue eliminada');
     return redirect()->route('Administrador.carreras.index');
 }
 public function store(Request $request)
 {
     //dd('jajaja');
     $file = $request->file('file');
     //obtenemos el campo file obtenido por el formulario
     if (is_null($request->file('file'))) {
         Session::flash('message', 'Seleccion el archivo');
         return redirect()->back();
     }
     //obtenemos el campo file obtenido por el formulario
     $nombre = $file->getClientOriginalName();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre, \File::get($file));
     $escuelas = $request->get('escuelas');
     $falla = false;
     \Excel::load('/storage/public/files/' . $nombre, function ($archivo) use(&$falla) {
         $result = $archivo->get();
         //leer todas las filas del archivo
         foreach ($result as $key => $value) {
             $escuelas = Escuela::whereNombre($value->escuela_id)->pluck('id');
             if (is_null($escuelas)) {
                 // El campus no existe, deberia hacer algo para mitigar esto, o retornarlo al usuario ...
             }
             $var = new Carrera();
             $datos = ['codigo' => $value->codigo, 'nombre' => $value->nombre, 'descripcion' => $value->descripcion, 'escuela_id' => $escuelas];
             $validator = Validator::make($datos, Carrera::storeRules());
             if ($validator->fails()) {
                 Session::flash('message', 'Las Carreras ya existen o el archivo ingresado no es valido');
                 $falla = true;
             } else {
                 $var->fill($datos);
                 $var->save();
             }
         }
     })->get();
     if ($falla) {
         // Fallo la validacion de algun campus, retornar al index con mensaje
         return redirect()->route('Administrador.carreras.index');
     }
     \Storage::delete($nombre);
     Session::flash('message', 'Las Carreras fueron agregadas exitosamente!');
     return redirect()->route('Administrador.carreras.index');
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Carrera::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'id_area' => $this->id_area]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
 public function show($id)
 {
     $carreras = Carrera::find($id);
     //dd($Campus);
     if ($carreras) {
         $data = array(array('codigo', 'nombre', 'descripcion', 'escuela_id'), array($carreras->codigo, $carreras->nombre, $carreras->descripcion, $carreras->escuelas->nombre));
         Excel::create('Carreras' . $carreras->nombre, function ($excel) use($data) {
             $excel->sheet('Sheetname', function ($sheet) use($data) {
                 $sheet->fromArray($data);
             });
         })->download('csv');
     } else {
         abort('404');
     }
 }
 public function actionSistemaExperto($id)
 {
     $negocio = new RespuestaExamenNegocio();
     $perfil = $negocio->procesarRespuestas($id);
     $resultadosExamen = new ResultadosExamen();
     $dataProvider = new ActiveDataProvider(['query' => ResultadosExamen::find()->where(['id_inscripcion' => $id])->orderBy(['id_area' => SORT_ASC])]);
     if ($perfil != null) {
         $valor = $perfil->getValor();
     } else {
         $valor = 'no se encontro un resultado';
     }
     if (strcasecmp($valor, \app\SistemaExperto\backwardchain::$DEFINIDO) == 0) {
         $profesion = $negocio->encontrarArea($id);
         $carrera = new ActiveDataProvider(['query' => Carrera::find()->where(['id_area' => $profesion->id_area])]);
     } else {
         $profesion = null;
         $carrera = null;
     }
     return $this->render('resultado', ['dataProvider' => $dataProvider, 'perfil' => $valor, 'profesion' => $profesion, 'carrera' => $carrera]);
 }
 public function edit($id)
 {
     $estudiantes = Estudiante::findOrFail($id);
     $carreras = Carrera::lists('nombre', 'id');
     return view('Administrador.EstudianteCrud.editarEstudiantes', compact('estudiantes', 'carreras'));
 }
示例#7
0
 /**
  * Finds the Carrera model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Carrera the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Carrera::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function edit($id)
 {
     $estudiantes = Estudiante::findOrFail($id);
     $carreras = Carrera::lists('nombre', 'id');
     return view('Encargado.Estudiante.editarEstudiantesE', compact('estudiantes', 'carreras'));
 }