mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 11:03:34 -05:00 
			
		
		
		
	Merge pull request #7265 from turbo124/v5-develop
Fixes for client limits on hosted
This commit is contained in:
		
						commit
						70200f22c8
					
				@ -76,7 +76,7 @@ class StoreClientRequest extends Request
 | 
			
		||||
                                        ];
 | 
			
		||||
 | 
			
		||||
        if (auth()->user()->company()->account->isFreeHostedClient()) {
 | 
			
		||||
            $rules['hosted_clients'] = new CanStoreClientsRule($this->company_id);
 | 
			
		||||
            $rules['id'] = new CanStoreClientsRule(auth()->user()->company()->id);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $rules['number'] = ['nullable',Rule::unique('clients')->where('company_id', auth()->user()->company()->id)];
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,8 @@ class CanStoreClientsRule implements Rule
 | 
			
		||||
{
 | 
			
		||||
    public $company_id;
 | 
			
		||||
 | 
			
		||||
    public $company;
 | 
			
		||||
 | 
			
		||||
    public function __construct($company_id)
 | 
			
		||||
    {
 | 
			
		||||
        $this->company_id = $company_id;
 | 
			
		||||
@ -33,9 +35,9 @@ class CanStoreClientsRule implements Rule
 | 
			
		||||
     */
 | 
			
		||||
    public function passes($attribute, $value)
 | 
			
		||||
    {
 | 
			
		||||
        $company = Company::find($this->company_id);
 | 
			
		||||
        $this->company = Company::find($this->company_id);
 | 
			
		||||
 | 
			
		||||
        return $company->clients->count() < $company->account->hosted_client_count;
 | 
			
		||||
        return $this->company->clients()->count() < $this->company->account->hosted_client_count;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -43,6 +45,6 @@ class CanStoreClientsRule implements Rule
 | 
			
		||||
     */
 | 
			
		||||
    public function message()
 | 
			
		||||
    {
 | 
			
		||||
        return ctrans('texts.limit_clients', ['count' => $company->account->hosted_client_count]);
 | 
			
		||||
        return ctrans('texts.limit_clients', ['count' => $this->company->account->hosted_client_count]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user