public function authenticate(Request $request)
 {
     $credentials = $request->only('username', 'password');
     try {
         // verify the credentials and create a token for the user
         if (!($token = JWTAuth::attempt($credentials))) {
             return response()->json(['error' => 'invalid_credentials'], 401);
         }
     } catch (JWTException $e) {
         // something went wrong
         return response()->json(['error' => 'could_not_create_token'], 500);
     }
     $user = User::where('username', '=', $request->username)->first();
     $categoria = $user->users_idcat_foreign;
     //var_dump($user);
     $empleado = Empleado::where('empleado_idcat_foreign', '=', $categoria)->first();
     //var_dump($empleado);
     $iduser = $empleado->id;
     // if no errors are encountered we can return a JWT
     return response()->json(compact('token', 'categoria', 'iduser'));
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }