From 7eb5594b33f3816bd36c709ffc20c65a4121b14b Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 13 Nov 2020 16:55:22 +0100 Subject: [PATCH] Reset array keys for restoration --- src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php | 2 ++ src/Illuminate/Database/Eloquent/Relations/MorphPivot.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php b/src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php index c40d2db8e755..de9f07253381 100644 --- a/src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php +++ b/src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php @@ -284,6 +284,8 @@ public function newQueryForRestoration($ids) */ protected function newQueryForCollectionRestoration(array $ids) { + $ids = array_values($ids); + if (! Str::contains($ids[0], ':')) { return parent::newQueryForRestoration($ids); } diff --git a/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php b/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php index 0db82ba101bc..68489265f838 100644 --- a/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php +++ b/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php @@ -139,6 +139,8 @@ public function newQueryForRestoration($ids) */ protected function newQueryForCollectionRestoration(array $ids) { + $ids = array_values($ids); + if (! Str::contains($ids[0], ':')) { return parent::newQueryForRestoration($ids); }