From 0dc4d6464c74ec8878f8b382ba43cdf016410a17 Mon Sep 17 00:00:00 2001 From: Ed Grosvenor Date: Thu, 28 Nov 2024 11:12:07 +0100 Subject: [PATCH] Fix the issue for non-incrementing ids as gently as possible --- src/Illuminate/Database/Schema/Blueprint.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index a0311db8d7ab..7dc421528df7 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -1052,6 +1052,12 @@ public function foreignIdFor($model, $column = null) ->referencesModelColumn($model->getKeyName()); } + if ($model->getKeyType() === 'int') { + return $this->foreignId($column) + ->table($model->getTable()) + ->referencesModelColumn($model->getKeyName()); + } + return $this->foreignUuid($column) ->table($model->getTable()) ->referencesModelColumn($model->getKeyName());