From 09c074e2526e6d2c5410e07bea31953f4723428c Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 7 Dec 2023 12:28:39 +1100 Subject: [PATCH] Resolve the user key via `getKey` --- src/Pulse.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Pulse.php b/src/Pulse.php index 9983e6be..4c53f358 100644 --- a/src/Pulse.php +++ b/src/Pulse.php @@ -338,10 +338,14 @@ public function resolveUsers(Collection $ids): Collection { if ($this->usersResolver) { return collect(($this->usersResolver)($ids)); - } elseif (class_exists(\App\Models\User::class)) { - return \App\Models\User::whereKey($ids)->get(['id', 'name', 'email']); - } elseif (class_exists(\App\User::class)) { - return \App\User::whereKey($ids)->get(['id', 'name', 'email']); + } + + if (class_exists($class = \App\Models\User::class) || class_exists($class = \App\User::class)) { + return $class::whereKey($ids)->get()->map(fn ($user) => [ + 'id' => $user->getKey(), + 'name' => $user->name, + 'email' => $user->email, + ]); } return $ids->map(fn (string|int $id) => [