2015-11-01 19:21:11 +01:00
|
|
|
<?php namespace App\Ninja\Repositories;
|
|
|
|
|
|
|
|
use DB;
|
|
|
|
use Utils;
|
|
|
|
|
|
|
|
class ReferralRepository
|
|
|
|
{
|
|
|
|
public function getCounts($userId)
|
|
|
|
{
|
|
|
|
$accounts = DB::table('accounts')
|
|
|
|
->where('referral_user_id', $userId)
|
|
|
|
->get(['id', 'pro_plan_paid']);
|
|
|
|
|
|
|
|
$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-17 00:34:39 +02:00
|
|
|
if ($account->isPro()) {
|
2015-11-01 19:21:11 +01:00
|
|
|
$counts['pro']++;
|
2016-04-17 00:34:39 +02:00
|
|
|
if ($account->isEnterprise()) {
|
|
|
|
$counts['enterprise']++;
|
|
|
|
}
|
2015-11-01 19:21:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $counts;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|