payfrit-api/api/beacons/get.php
John Mizerek 1f81d98c52 Initial PHP API migration from CFML
Complete port of all 163 API endpoints from Lucee/CFML to PHP 8.3.
Shared helpers in api/helpers.php (DB, auth, request/response, security).
PDO prepared statements throughout. Same JSON response shapes as CFML.
2026-03-14 14:26:59 -07:00

39 lines
938 B
PHP

<?php
require_once __DIR__ . '/../helpers.php';
runAuth();
global $businessId;
$data = readJsonBody();
$beaconID = (int) ($data['BeaconID'] ?? 0);
if ($beaconID <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'missing_beacon_id', 'MESSAGE' => 'BeaconID is required']);
}
$q = queryOne("
SELECT b.ID, b.BusinessID, b.Name, b.UUID, b.IsActive
FROM Beacons b
WHERE b.ID = ?
AND (b.BusinessID = ? OR EXISTS (
SELECT 1 FROM lt_BeaconsID_BusinessesID lt
WHERE lt.BeaconID = b.ID AND lt.BusinessID = ?
))
LIMIT 1
", [$beaconID, $businessId, $businessId]);
if (!$q) {
apiAbort(['OK' => false, 'ERROR' => 'not_found']);
}
jsonResponse([
'OK' => true,
'ERROR' => '',
'BEACON' => [
'BeaconID' => (int) $q['ID'],
'BusinessID' => (int) $q['BusinessID'],
'Name' => $q['Name'],
'UUID' => $q['UUID'],
'IsActive' => (int) $q['IsActive'],
],
]);