diff --git a/app/Filters/UserFilters.php b/app/Filters/UserFilters.php index ec3c0a08fd9a..b0079e339189 100644 --- a/app/Filters/UserFilters.php +++ b/app/Filters/UserFilters.php @@ -88,4 +88,25 @@ class UserFilters extends QueryFilters ->orderByRaw("{$this->with_property} = ? DESC", [$value]) ->where('account_id', auth()->user()->account_id); } + + /** + * Exclude a list of user_ids, can pass multiple + * user IDs by separating them with a comma. + * + * @param string $user_id + * @return Builder + */ + public function without(string $user_id = ''): Builder + { + if (strlen($user_id) == 0) { + return $this->builder; + } + + $user_array = $this->transformKeys(explode(',', $user_id)); + + return $this->builder->where(function ($query) use ($user_array) { + $query->whereNotIn('id', $user_array) + ->where('account_id', auth()->user()->account_id); + }); + } }