Deploy: 2026-05-23 02:42:32

This commit is contained in:
Hamza-Ayed
2026-05-23 02:42:32 +03:00
parent 71e609d869
commit 1814f69ecb
6 changed files with 196 additions and 8 deletions

View File

@@ -60,6 +60,24 @@ class StaffController extends BaseController
return;
}
// Fetch subscription limits for agents
$activeSub = \App\Models\CompanySubscription::findActiveByCompany($companyId);
$maxAgents = 1;
if (isset($request->is_super_admin) && $request->is_super_admin) {
$maxAgents = 999;
} elseif ($activeSub) {
$maxAgents = (int)($activeSub['max_agents'] ?? 1);
}
$currentStaffCount = Database::selectOne("SELECT COUNT(*) as count FROM users WHERE company_id = ? AND role = 'staff'", [$companyId])['count'] ?? 0;
if ($currentStaffCount >= $maxAgents) {
$response->status(400)->json([
'status' => 'error',
'error' => "You have reached the maximum number of staff agents allowed by your plan ({$maxAgents})."
]);
return;
}
$body = $request->getBody();
$email = strtolower(trim($body['email']));