mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Merge pull request #6939 from turbo124/v5-develop
Change logic for adding user
This commit is contained in:
commit
52a49f1b18
@ -12,6 +12,7 @@
|
||||
namespace App\Http\ValidationRules\Ninja;
|
||||
|
||||
use App\Models\CompanyUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
/**
|
||||
@ -32,12 +33,22 @@ class CanAddUserRule implements Rule
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
$count = CompanyUser::query()
|
||||
->with('user')
|
||||
// $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');
|
||||
}])
|
||||
->where('account_id', auth()->user()->account_id)
|
||||
->distinct()
|
||||
->select('user_id')
|
||||
->count();
|
||||
->select('users.id')
|
||||
->count();
|
||||
|
||||
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