code's snippets

2462 단어
public function edit(Request $request) { $arr_validate_field = array('tel', 'name', 'position'); $arr_error = $this->validateInput($request, $arr_validate_field);
   if (empty($arr_error)) {
       $arr_error = ['errmsg' => '          '];
      if ($request->input('id')) {
           $arr_old = DB::table('user')->where('id', $request->input('id'))->first();
           if ($arr_old) {
               $this->updateInfo($request, $arr_old);
           }
       }
   } else {
       $arr_error = ['errmsg' => array_shift($arr_error)];
   }
  return $this->responseJson($arr_error);

}
private function updateInfo($request, $arr_old) { $arr_data = [ 'tel' => $request['tel'], 'name' => $request['name'], 'token' => uniqid('update_'), 'position' => $request['position'], 'update' => date('Y-m-d H:i:s') ]; if ($request->input('resetpass')) { $arr_data['password'] = $request['tel']; } $arr_new = $this->dataRecord($arr_data); $arr_data = array_merge(get_object_vars($arr_old), $arr_new);
   return DB::table("user")->where('id', $request->input('id'))->update($arr_data);

}
function dataLength($payload, &$arr_data) { $data_len_hex = base_convert(ceil(strlen($payload)/2), 10, 16); $len = strlen($data_len_hex); if ($len < 4) { $data_len_hex = str_repeat('0', 4 - $len) . $data_len_hex; }
   $arr_data['data_len'] = $data_len_hex;

}
function sendMessageByCurl($connection, $data) { global $active_socket; global $aes;
   $arr_command_data = CommandPattern::FormatCommandPattern($data, $aes);
   $arr_data = $arr_command_data['data'];
   $command = $arr_command_data['data']['command'];
   $device_mac = $arr_command_data['device_mac'];
   $ipport = $connection->getRemoteIp() . ":" . $connection->getRemotePort();
   $key = $device_mac . '_' . $ipport;
   $active_socket[$key] = $connection;
   $arr_laravel_ret = telegramWithLaravel($command, $arr_data, $ipport);
   responseDevice($connection, $aes, $arr_data, $arr_laravel_ret);

}

좋은 웹페이지 즐겨찾기