1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-24 10:21:35 +02:00
invoiceninja/app/Ninja/Repositories/ReferralRepository.php
2016-04-16 18:34:39 -04:00

35 lines
718 B
PHP

<?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,
'pro' => 0,
'enterprise' => 0
];
foreach ($accounts as $account) {
$counts['free']++;
if ($account->isPro()) {
$counts['pro']++;
if ($account->isEnterprise()) {
$counts['enterprise']++;
}
}
}
return $counts;
}
}