1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Ninja/Repositories/ReferralRepository.php

32 lines
706 B
PHP
Raw Normal View History

2015-11-01 19:21:11 +01:00
<?php namespace App\Ninja\Repositories;
use App\Models\Account;
2015-11-01 19:21:11 +01:00
use Utils;
class ReferralRepository
{
public function getCounts($userId)
{
$accounts = Account::where('referral_user_id', $userId);
2015-11-01 19:21:11 +01:00
$counts = [
'free' => 0,
2016-04-17 00:34:39 +02:00
'pro' => 0,
'enterprise' => 0
2015-11-01 19:21:11 +01:00
];
foreach ($accounts as $account) {
$counts['free']++;
$plan = $account->getPlanDetails(false, false);
if ($plan) {
2015-11-01 19:21:11 +01:00
$counts['pro']++;
if ($plan['plan'] == PLAN_ENTERPRISE) {
2016-04-17 00:34:39 +02:00
$counts['enterprise']++;
}
2015-11-01 19:21:11 +01:00
}
}
return $counts;
}
}