From 499d9f6b86f435e76a3166b61bc582659a0e20a2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 15 May 2021 17:00:17 +1000 Subject: [PATCH] Fixes for client portal constraint --- app/Http/Middleware/CheckClientExistence.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Middleware/CheckClientExistence.php b/app/Http/Middleware/CheckClientExistence.php index fb6f089c5244..bab04bc5678a 100644 --- a/app/Http/Middleware/CheckClientExistence.php +++ b/app/Http/Middleware/CheckClientExistence.php @@ -32,7 +32,6 @@ class CheckClientExistence ->where('email', auth('contact')->user()->email) ->whereNotNull('email') ->where('email', '<>', '') - ->where('account_id', auth('contact')->user()->client->company->account->id) ->whereNull('deleted_at') ->distinct('company_id') ->distinct('email') @@ -40,6 +39,9 @@ class CheckClientExistence ->whereHas('client', function ($query) { return $query->whereNull('deleted_at'); }) + ->whereHas('client.company', function ($query){ + return $query->where('account_id', auth('contact')->user()->client->company->account->id); + }) ->get(); if (count($multiple_contacts) == 0) {