2015-11-01 19:21:11 +01:00
|
|
|
<?php namespace App\Ninja\Repositories;
|
|
|
|
|
2016-04-19 04:35:18 +02:00
|
|
|
use App\Models\Account;
|
2015-11-01 19:21:11 +01:00
|
|
|
use Utils;
|
|
|
|
|
|
|
|
class ReferralRepository
|
|
|
|
{
|
|
|
|
public function getCounts($userId)
|
|
|
|
{
|
2016-04-19 04:35:18 +02:00
|
|
|
$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']++;
|
2016-04-19 04:35:18 +02:00
|
|
|
$plan = $account->getPlanDetails(false, false);
|
|
|
|
|
|
|
|
if ($plan) {
|
2015-11-01 19:21:11 +01:00
|
|
|
$counts['pro']++;
|
2016-04-19 04:35:18 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|