mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			472 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			472 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Services;
 | |
| 
 | |
| use App\Models\Plan;
 | |
| use App\Models\User;
 | |
| 
 | |
| class PlanService
 | |
| {
 | |
|     public $plan;
 | |
| 
 | |
|     public function __construct(int $planId)
 | |
|     {
 | |
|         $this->plan = Plan::lockForUpdate()->find($planId);
 | |
|     }
 | |
| 
 | |
|     public function haveCapacity(): bool
 | |
|     {
 | |
|         if ($this->plan->capacity_limit === 0) return true;
 | |
|         $count = User::where('plan_id', $this->plan->plan_id)->count();
 | |
|         return $this->plan->capacity_limit - $count;
 | |
|     }
 | |
| }
 |