Skip to content

Commit

Permalink
Merge pull request #8 from mitydigital/fix/user-name-checks
Browse files Browse the repository at this point in the history
Add checking for `name()` method
  • Loading branch information
martyf authored Jun 23, 2024
2 parents 0885280 + 6a4e543 commit 52be9db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Listeners/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ protected function data($event): array
];
}

$name = $event->user->id;
if (method_exists($event->user, 'name')) {
$name = $event->user->name();
} elseif ($event->user->name) {
$name = $event->user->name;
}

return [
'id' => $event->user->id,
'name' => $event->user->name(),
'name' => $name,
];
}

Expand Down

0 comments on commit 52be9db

Please sign in to comment.