1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Ninja/Repositories/ReferralRepository.php

34 lines
693 B
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Repositories;
2015-11-01 19:21:11 +01:00
use App\Models\Account;
2015-11-01 19:21:11 +01:00
class ReferralRepository
{
public function getCounts($userId)
{
2016-06-05 18:10:15 +02:00
$accounts = Account::where('referral_user_id', $userId)->get();
2015-11-01 19:21:11 +01:00
$counts = [
'free' => 0,
2016-04-17 00:34:39 +02:00
'pro' => 0,
2017-01-30 20:40:43 +01:00
'enterprise' => 0,
2015-11-01 19:21:11 +01:00
];
foreach ($accounts as $account) {
$counts['free']++;
$plan = $account->getPlanDetails(false, false);
2016-06-05 18:10:15 +02:00
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;
}
2016-06-05 18:10:15 +02:00
}