mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
0fbda85a59
- Removed unused uses - Type hinting for method parameters - Removed commented code - Introduced comments for classes and methods - Short array syntax
32 lines
691 B
PHP
32 lines
691 B
PHP
<?php namespace App\Ninja\Repositories;
|
|
|
|
use App\Models\Account;
|
|
|
|
class ReferralRepository
|
|
{
|
|
public function getCounts($userId)
|
|
{
|
|
$accounts = Account::where('referral_user_id', $userId)->get();
|
|
|
|
$counts = [
|
|
'free' => 0,
|
|
'pro' => 0,
|
|
'enterprise' => 0
|
|
];
|
|
|
|
foreach ($accounts as $account) {
|
|
$counts['free']++;
|
|
$plan = $account->getPlanDetails(false, false);
|
|
|
|
if ($plan) {
|
|
$counts['pro']++;
|
|
if ($plan['plan'] == PLAN_ENTERPRISE) {
|
|
$counts['enterprise']++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $counts;
|
|
}
|
|
}
|