From 7b6ee68bca7bb174c3008fee4f97dfa3443923ef Mon Sep 17 00:00:00 2001 From: Dan Wiser Date: Sat, 17 Feb 2024 03:50:25 -0500 Subject: [PATCH] Don't use hardcoded primary key name Not all User models use 'id' as the primary key. For example, Mine is 'uuid'. `->getKey()` automatically gets the primary key value for us. --- src/Commands/MakeShieldSuperAdminCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/MakeShieldSuperAdminCommand.php b/src/Commands/MakeShieldSuperAdminCommand.php index e62072c..8b00801 100644 --- a/src/Commands/MakeShieldSuperAdminCommand.php +++ b/src/Commands/MakeShieldSuperAdminCommand.php @@ -65,7 +65,7 @@ public function handle(): int ['ID', 'Name', 'Email', 'Roles'], static::getUserModel()::with('roles')->get()->map(function (Authenticatable $user) { return [ - 'id' => $user->getAttribute('id'), + 'id' => $user->getKey(), 'name' => $user->getAttribute('name'), 'email' => $user->getAttribute('email'), /** @phpstan-ignore-next-line */