payfrit-api/api/businesses/setHiring.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

30 lines
725 B
PHP

<?php
require_once __DIR__ . '/../helpers.php';
runAuth();
/**
* Set Business Hiring Status
* POST: { BusinessID, IsHiring: bool }
*/
$data = readJsonBody();
$businessId = (int) ($data['BusinessID'] ?? 0);
if ($businessId <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'missing_business_id']);
}
if (!isset($data['IsHiring'])) {
apiAbort(['OK' => false, 'ERROR' => 'missing_is_hiring']);
}
$isHiring = $data['IsHiring'] ? 1 : 0;
try {
queryTimed("UPDATE Businesses SET IsHiring = ? WHERE ID = ?", [$isHiring, $businessId]);
jsonResponse(['OK' => true, 'IsHiring' => $isHiring === 1]);
} catch (Exception $e) {
apiAbort(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]);
}