From d0ad38cb187a405361c0be36a4a1f2998b7d6b7c Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 7 Aug 2024 17:31:26 +0100 Subject: [PATCH] [5.x] Prevent error when Laravel Telescope serializes a user before its created (#10586) --- src/Auth/User.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Auth/User.php b/src/Auth/User.php index 01cdb0bd84..9390a4c1cd 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -105,16 +105,28 @@ public function isTaxonomizable() public function editUrl() { - return cp_route('users.edit', $this->id()); + if (! $id = $this->id()) { + return null; + } + + return cp_route('users.edit', $id); } public function updateUrl() { - return cp_route('users.update', $this->id()); + if (! $id = $this->id()) { + return null; + } + + return cp_route('users.update', $id); } public function apiUrl() { + if (! $id = $this->id()) { + return null; + } + return Statamic::apiRoute('users.show', $this->id()); }