From 64e2ae0c5772b6854bac634170ae1a3b49b1ac10 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 24 Jul 2023 19:39:46 +1000 Subject: [PATCH] Filters for users that have been removed --- app/Filters/UserFilters.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Filters/UserFilters.php b/app/Filters/UserFilters.php index 20d2a7ce777f..9998d74a7c81 100644 --- a/app/Filters/UserFilters.php +++ b/app/Filters/UserFilters.php @@ -69,6 +69,19 @@ class UserFilters extends QueryFilters }); } + /** + * Filters users that have been removed from the + * company, but not deleted from the system. + * + * @return void + */ + public function hideRemovedUsers() + { + return $this->builder->whereHas('company_users', function ($q) { + $q->where('company_id', '=', auth()->user()->company()->id)->whereNull('deleted_at'); + }); + } + /** * Overrides the base with() function as no company ID * exists on the user table