1
0
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:
David Bomba 2021-11-07 22:12:54 +11:00
parent dd834f1405
commit 2a7bdc8d59
3 changed files with 13 additions and 28 deletions

View File

@ -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());

View File

@ -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;
}
/**

View File

@ -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;
}
/**