mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for client limits on hosted
This commit is contained in:
parent
b4303d0b57
commit
c65948d10c
@ -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