Deploy: 2026-05-23 02:42:32
This commit is contained in:
@@ -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']));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user