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