コード例 #1
0
 public function user_connect_many(Request $request)
 {
     if (!\Session::get('user')->is_admin()) {
         abort(401);
     }
     $users = (array) $request->input('users');
     $role = Role::find($request->input('id'));
     $connected_users = (array) $role->users()->lists('id')->all();
     $inter_users = (array) array_intersect($connected_users, $users);
     $new_users = array_diff($users, $inter_users);
     foreach ($new_users as $uid) {
         $user = User::find($uid);
         if ($user) {
             $role->users()->save($user);
             \Log::warning(strtr('角色设定: 用户(%name[%id]) 设定为角色[%role]', ['%name' => $user->name, '%id' => $user->id, '%role' => $role->name]));
         }
     }
     return response()->json(['id' => $role->id, 'view' => (string) view('roles/view', ['role' => $role])]);
 }
コード例 #2
0
ファイル: NodesController.php プロジェクト: afdalwahyu/lnms
 public function snmp($id)
 {
     $node = \App\Node::findOrFail($id);
     $snmp = new \App\Lnms\Snmp($node->ip_address, $node->snmp_comm_ro);
     $get = $snmp->get('.1.3.6.1.2.1.1.2.0');
     if ($snmp->getErrno() == 0) {
         // snmp ok
         $snmp_success = 100;
     } else {
         // snmp fail
         $snmp_success = 0;
     }
     if ($snmp_success != $node->snmp_success) {
         \Log::warning('nodes/' . $node->id . ' snmp changed to ' . $snmp_success);
         $node->snmp_success = $snmp_success;
         $node->snmp_changed = \Carbon\Carbon::now();
         // update snmp success changed
         $node->save();
     }
     return response()->json(['snmp_success' => $snmp_success]);
 }