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'))
|
if(!$request->has('entity_id'))
|
||||||
$entity_obj->service()->fillDefaults()->save();
|
$entity_obj->service()->fillDefaults()->save();
|
||||||
|
|
||||||
// $entity_obj->load('client.contacts','client.company');
|
|
||||||
|
|
||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
App::setLocale($entity_obj->client->locale());
|
App::setLocale($entity_obj->client->locale());
|
||||||
|
@ -33,25 +33,14 @@ class CanAddUserRule implements Rule
|
|||||||
public function passes($attribute, $value)
|
public function passes($attribute, $value)
|
||||||
{
|
{
|
||||||
|
|
||||||
// $count = CompanyUser::query()
|
$count = CompanyUser::query()
|
||||||
// ->with('user')
|
->where('account_id', auth()->user()->account_id)
|
||||||
// ->where('account_id', auth()->user()->account_id)
|
->whereNull('deleted_at')
|
||||||
// ->distinct()
|
->distinct()
|
||||||
// ->select('user_id')
|
->count('user_id');
|
||||||
// ->count();
|
|
||||||
|
|
||||||
|
|
||||||
$count = User::query()
|
|
||||||
->with(['company_user' => function ($query){
|
|
||||||
return $query->whereNull('company_user.deleted_at');
|
|
||||||
}])
|
|
||||||
->where('account_id', auth()->user()->account_id)
|
|
||||||
->distinct()
|
|
||||||
->select('users.id')
|
|
||||||
->count();
|
|
||||||
|
|
||||||
return $count < auth()->user()->company()->account->num_users;
|
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)
|
public function passes($attribute, $value)
|
||||||
{
|
{
|
||||||
|
|
||||||
$count = User::query()
|
$count = CompanyUser::query()
|
||||||
->with(['company_user' => function ($query){
|
->where('account_id', auth()->user()->account_id)
|
||||||
return $query->whereNull('company_user.deleted_at');
|
->whereNull('deleted_at')
|
||||||
}])
|
->distinct()
|
||||||
->where('account_id', 1)
|
->count('user_id');
|
||||||
->distinct()
|
|
||||||
->select('users.id')
|
|
||||||
->count();
|
|
||||||
|
|
||||||
return $count < auth()->user()->company()->account->num_users;
|
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