Fixed issue when you create plan with 0 team members amount

This commit is contained in:
Čarodej
2022-05-10 10:48:05 +02:00
parent 6472997cc1
commit 8c75166980
6 changed files with 13 additions and 9 deletions

View File

@@ -94,10 +94,15 @@ class UserLimitation extends Model
$totalUsedEmails = $memberEmails->merge($InvitationEmails)
->unique();
// Get usage in percent
$percentage = (int) $this->max_team_members === 0
? 100
: ($totalUsedEmails->count() / $this->max_team_members) * 100;
return [
'use' => $totalUsedEmails->count(),
'total' => (int) $this->max_team_members,
'percentage' => ($totalUsedEmails->count() / $this->max_team_members) * 100,
'percentage' => $percentage,
'meta' => [
'allowed_emails' => $totalUsedEmails,
],