Skip to content

Commit

Permalink
Resolve the user key via getKey
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Dec 7, 2023
1 parent 77b2de2 commit 09c074e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) => [
Expand Down

0 comments on commit 09c074e

Please sign in to comment.