2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Repositories;
|
2015-11-01 19:21:11 +01:00
|
|
|
|
2016-04-19 04:35:18 +02: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']++;
|
2016-04-19 04:35:18 +02:00
|
|
|
$plan = $account->getPlanDetails(false, false);
|
2016-06-05 18:10:15 +02:00
|
|
|
|
2016-04-19 04:35:18 +02:00
|
|
|
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;
|
|
|
|
}
|
2016-06-05 18:10:15 +02:00
|
|
|
}
|