29 lines
711 B
PHP
29 lines
711 B
PHP
<?php
|
|
/**
|
|
* Tenants List Endpoint (Super Admin Only)
|
|
*/
|
|
|
|
use App\Core\Database;
|
|
use App\Middleware\AuthMiddleware;
|
|
|
|
$decoded = AuthMiddleware::check();
|
|
|
|
if ($decoded['role'] !== 'super_admin') {
|
|
json_error('Unauthorized', 403);
|
|
}
|
|
|
|
$db = Database::getInstance();
|
|
|
|
$stmt = $db->query("SELECT id, name, email, phone, status, created_at FROM tenants ORDER BY created_at DESC");
|
|
$tenants = $stmt->fetchAll();
|
|
|
|
foreach ($tenants as &$t) {
|
|
$decName = \App\Core\Encryption::decrypt($t['name']);
|
|
$t['name'] = $decName !== false ? $decName : $t['name'];
|
|
|
|
$decEmail = \App\Core\Encryption::decrypt($t['email']);
|
|
$t['email'] = $decEmail !== false ? $decEmail : $t['email'];
|
|
}
|
|
|
|
json_success($tenants);
|