예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $res = ["success" => false];
     try {
         Becario::create(['cve_uaslp' => $request['cve_uaslp'], 'rpe' => $request['rpe'], 'password' => bcrypt($request['password']), 'activo' => '1']);
         LaboratorioBec::create(['id_laboratorios' => Session::get('id_lab'), 'clave_uaslp' => $request['cve_uaslp'], 'id_semestre' => '1']);
         $res["success"] = true;
         $res["msg"] = "El becario se ha registrado <strong>correctamente!</strong>";
         $res["tipo"] = "success";
     } catch (Exception $e) {
         $res["tipo"] = "danger";
         $res["msg"] = "Los datos son incorrectos";
     }
     return response()->json($res);
 }
예제 #2
0
 public function postLogin(Request $request)
 {
     //dd( $this->getCredentials($request) );
     $this->validate($request, ['cve_uaslp' => 'required', 'password' => 'required']);
     $credentials = $request->only('cve_uaslp', 'password');
     $clave = $request->only('cve_uaslp');
     $id_lab = LaboratorioBec::select('id_laboratorios')->where('clave_uaslp', $clave['cve_uaslp'])->lists('id_laboratorios')->first();
     $lab = Laboratorio::find($id_lab);
     //return $credentials;
     if (Auth::attempt($credentials, $request->has('remember'))) {
         //$_SESSION['laboratorio'] = $lab;
         Session::put('laboratorio', $lab->laboratorio);
         Session::put('clave', $clave['cve_uaslp']);
         Session::put('id_lab', $id_lab);
         return redirect()->intended($this->redirectPath());
         //return view('laboratorio.index',array('laboratorio' => $lab));
     }
     return redirect($this->loginPath())->withInput($request->only('cve_uaslp', 'remember'))->withErrors(['cve_uaslp' => 'Las credenciales son incorrectas (Clave/Password).']);
 }