mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for User Add rules in hosted
This commit is contained in:
parent
dd834f1405
commit
2a7bdc8d59
@ -217,8 +217,6 @@ class PreviewController extends BaseController
|
||||
if(!$request->has('entity_id'))
|
||||
$entity_obj->service()->fillDefaults()->save();
|
||||
|
||||
// $entity_obj->load('client.contacts','client.company');
|
||||
|
||||
App::forgetInstance('translator');
|
||||
$t = app('translator');
|
||||
App::setLocale($entity_obj->client->locale());
|
||||
|
@ -33,25 +33,14 @@ class CanAddUserRule implements Rule
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
// $count = CompanyUser::query()
|
||||
// ->with('user')
|
||||
// ->where('account_id', auth()->user()->account_id)
|
||||
// ->distinct()
|
||||
// ->select('user_id')
|
||||
// ->count();
|
||||
|
||||
|
||||
$count = User::query()
|
||||
->with(['company_user' => function ($query){
|
||||
return $query->whereNull('company_user.deleted_at');
|
||||
}])
|
||||
$count = CompanyUser::query()
|
||||
->where('account_id', auth()->user()->account_id)
|
||||
->whereNull('deleted_at')
|
||||
->distinct()
|
||||
->select('users.id')
|
||||
->count();
|
||||
->count('user_id');
|
||||
|
||||
return $count < auth()->user()->company()->account->num_users;
|
||||
//return auth()->user()->company()->account->users->count() < auth()->user()->company()->account->num_users;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,17 +33,15 @@ class CanRestoreUserRule implements Rule
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
$count = User::query()
|
||||
->with(['company_user' => function ($query){
|
||||
return $query->whereNull('company_user.deleted_at');
|
||||
}])
|
||||
->where('account_id', 1)
|
||||
$count = CompanyUser::query()
|
||||
->where('account_id', auth()->user()->account_id)
|
||||
->whereNull('deleted_at')
|
||||
->distinct()
|
||||
->select('users.id')
|
||||
->count();
|
||||
->count('user_id');
|
||||
|
||||
|
||||
return $count < auth()->user()->company()->account->num_users;
|
||||
//return auth()->user()->company()->account->users->count() < auth()->user()->company()->account->num_users;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user