From 3f57a4cd069ad9442ab2082ffafa4f4186e41ce8 Mon Sep 17 00:00:00 2001 From: Firuzbek Bakhadyrov Date: Mon, 15 Jul 2024 20:25:27 +0500 Subject: [PATCH] Fix: Cast model key to integer to improve query performance on PostgreSQL (#524) --- src/PersonalAccessToken.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PersonalAccessToken.php b/src/PersonalAccessToken.php index c9aa8916..13e533d4 100644 --- a/src/PersonalAccessToken.php +++ b/src/PersonalAccessToken.php @@ -63,6 +63,10 @@ public static function findToken($token) [$id, $token] = explode('|', $token, 2); + if ((new static())->getKeyType() === 'int') { + $id = (int) $id; + } + if ($instance = static::find($id)) { return hash_equals($instance->token, hash('sha256', $token)) ? $instance : null; }