home/skymarketplace/public_html/controllers/UserController.php 0000644 00000001631 15003677745 0021075 0 ustar 00 model = new UserModel($database->getConnection());
}
public function deleteUser(int $id): void
{
if (!$id || !is_numeric($id)) {
$this->jsonResponse(false, 'Invalid user ID');
return;
}
if ($this->model->deleteUserById($id)) {
$this->jsonResponse(true, 'User deleted successfully');
} else {
$this->jsonResponse(false, 'Failed to delete user');
}
}
private function jsonResponse(bool $success, string $message): void
{
echo json_encode([
'status' => $success ? 'success' : 'error',
'message' => $message
]);
}
}