| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Models;
- class TshieldWebhookModel
- {
- private \PDO $pdo;
- public function __construct()
- {
- if (!isset($GLOBALS['pdo']) || !($GLOBALS['pdo'] instanceof \PDO)) {
- throw new \RuntimeException('Database connection not initialized.');
- }
- $this->pdo = $GLOBALS['pdo'];
- }
- public function approveByExternalId(string $externalId): bool
- {
- return $this->approveByExternalIds([$externalId]);
- }
- public function approveByExternalIds(array $externalIds): bool
- {
- $externalIds = array_values(array_unique(array_filter(array_map(static function ($id) {
- if (is_numeric($id)) {
- $id = (string)$id;
- }
- if (!is_string($id)) {
- return null;
- }
- $id = trim($id);
- return $id === '' ? null : $id;
- }, $externalIds))));
- if (empty($externalIds)) {
- return false;
- }
- $params = [];
- $placeholders = [];
- foreach ($externalIds as $i => $id) {
- $key = 'id' . $i;
- $placeholders[] = ':' . $key;
- $params[$key] = $id;
- }
- $sql = 'UPDATE "user" SET user_kyc = 1 '
- . 'WHERE kyc_external_id IN (' . implode(',', $placeholders) . ') '
- . 'AND user_flag = \'a\'';
- $stmt = $this->pdo->prepare($sql);
- $stmt->execute($params);
- return $stmt->rowCount() > 0;
- }
- }
|