integraçao site
This commit is contained in:
38
app/Controllers/IntegrationController.php
Normal file
38
app/Controllers/IntegrationController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\Domain;
|
||||
use App\Models\Setting;
|
||||
use App\Utils\View;
|
||||
|
||||
class IntegrationController
|
||||
{
|
||||
public function stats()
|
||||
{
|
||||
$orderModel = new Order();
|
||||
$domainModel = new Domain();
|
||||
$settingModel = new Setting();
|
||||
|
||||
// Orders metrics
|
||||
$totalOrders = $orderModel->countAll();
|
||||
$recentOrders = $orderModel->countRecent(7); // Last 7 days
|
||||
|
||||
// Domain metrics
|
||||
$blockedDomains = $domainModel->countBlocked();
|
||||
|
||||
// Last Update - Try specific key first, fallback to now if not set yet
|
||||
$lastUpdate = $settingModel->get('last_rpz_update');
|
||||
if (!$lastUpdate) {
|
||||
$lastUpdate = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
View::json([
|
||||
'orders_total' => $totalOrders,
|
||||
'orders_recent' => $recentOrders,
|
||||
'domains_blocked' => $blockedDomains,
|
||||
'last_update' => $lastUpdate
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user