26 lines
710 B
PHP
26 lines
710 B
PHP
<?php
|
|
/**
|
|
* Get Current Tenant Subscription & Usage
|
|
* GET /api/v1/subscriptions/current
|
|
*/
|
|
|
|
use App\Middleware\AuthMiddleware;
|
|
use App\Middleware\QuotaMiddleware;
|
|
|
|
$decoded = AuthMiddleware::check();
|
|
$tenantId = $decoded['tenant_id'];
|
|
|
|
try {
|
|
$usage = QuotaMiddleware::getUsageSummary($tenantId);
|
|
|
|
if (!$usage['has_subscription']) {
|
|
json_error('لم يتم العثور على اشتراك نشط لهذا المكتب.', 404);
|
|
}
|
|
|
|
json_success($usage, 'تفاصيل الاشتراك الحالي');
|
|
|
|
} catch (\Exception $e) {
|
|
error_log("Subscription Current Error: " . $e->getMessage());
|
|
json_error('حدث خطأ أثناء جلب بيانات الاشتراك', 500);
|
|
}
|