mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 22:27:32 -04:00 
			
		
		
		
	* Allow admins to change plan * Check features instead of plans * Support linking/unlinking accounts * Support creating/deleting accounts
		
			
				
	
	
		
			32 lines
		
	
	
		
			706 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			706 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php namespace App\Ninja\Repositories;
 | |
| 
 | |
| use App\Models\Account;
 | |
| use Utils;
 | |
| 
 | |
| class ReferralRepository
 | |
| {
 | |
|     public function getCounts($userId)
 | |
|     {
 | |
|         $accounts = Account::where('referral_user_id', $userId);
 | |
| 
 | |
|         $counts = [
 | |
|             'free' => 0,
 | |
|             'pro' => 0,
 | |
|             'enterprise' => 0
 | |
|         ];
 | |
| 
 | |
|         foreach ($accounts as $account) {
 | |
|             $counts['free']++;
 | |
|             $plan = $account->getPlanDetails(false, false);
 | |
|             
 | |
|             if ($plan) {
 | |
|                 $counts['pro']++;
 | |
|                 if ($plan['plan'] == PLAN_ENTERPRISE) {
 | |
|                     $counts['enterprise']++;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         return $counts;
 | |
|     }
 | |
| } |