mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Change logic for adding user
This commit is contained in:
parent
c91ab24d49
commit
27db04515a
@ -12,6 +12,7 @@
|
|||||||
namespace App\Http\ValidationRules\Ninja;
|
namespace App\Http\ValidationRules\Ninja;
|
||||||
|
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Validation\Rule;
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,11 +33,21 @@ class CanAddUserRule implements Rule
|
|||||||
public function passes($attribute, $value)
|
public function passes($attribute, $value)
|
||||||
{
|
{
|
||||||
|
|
||||||
$count = CompanyUser::query()
|
// $count = CompanyUser::query()
|
||||||
->with('user')
|
// ->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');
|
||||||
|
}])
|
||||||
->where('account_id', auth()->user()->account_id)
|
->where('account_id', auth()->user()->account_id)
|
||||||
->distinct()
|
->distinct()
|
||||||
->select('user_id')
|
->select('users.id')
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
return $count < auth()->user()->company()->account->num_users;
|
return $count < auth()->user()->company()->account->num_users;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user