Esempio n. 1
0
 public static function addAcl($data)
 {
     $city = City::with('state')->where('id', '=', $data['city'])->first();
     $acl = new Acl();
     $acl->dni = $data['dni'];
     $acl->topic = $city->state->name . '/' . $city->name . '/water/' . $acl->dni;
     //Definir Mendoza/water/dni
     $acl->rw = 1;
     $acl->save();
 }
Esempio n. 2
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');
     }
 }
Esempio n. 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = Acl::create(['dni' => '34785998', 'topic' => 'Mendoza/Godoy Cruz/water/34785998', 'rw' => '1']);
     //mqtt acl
     $user = Acl::create(['dni' => '34785666', 'topic' => 'Mendoza/+/water/+', 'rw' => '2']);
 }