Exemplo n.º 1
0
 public static function addUser($data)
 {
     //Agregar manejo de errores
     $password = shell_exec("/usr/bin/np -p" . $data['token']);
     //hasheado PBKDF2
     $mqtt = new UserMqtt();
     $mqtt->dni = $data['dni'];
     $mqtt->password = $password;
     $mqtt->super = 0;
     $mqtt->save();
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $password = shell_exec("/usr/bin/np -p 123456");
     $user = UserMqtt::create(['dni' => '34785998', 'password' => $password, 'super' => '0']);
     //mqtt subscriber
     $password = shell_exec("/usr/bin/np -p 123456");
     $user = UserMqtt::create(['dni' => '34785666', 'password' => $password, 'super' => '1']);
 }
Exemplo n.º 3
0
 public static function delete(Request $request, $id)
 {
     $user = User::find($id);
     if (!$user) {
         return redirect()->back()->withErrors('El usuario seleccionado no existe');
     }
     $acl = Acl::where('dni', '=', $user->dni)->delete();
     $mqtt = UserMqtt::where('dni', '=', $user->dni)->delete();
     $user->delete();
     if ($request->ajax()) {
         return response()->json(['code' => 200]);
     } else {
         return redirect()->route('users.index')->with('success', 'El usuario se ha eliminado correctamente');
     }
 }