diff --git a/src/Models/Behaviors/HasRelated.php b/src/Models/Behaviors/HasRelated.php index 139b07af8b..661a04e03b 100644 --- a/src/Models/Behaviors/HasRelated.php +++ b/src/Models/Behaviors/HasRelated.php @@ -65,8 +65,10 @@ public function loadRelated(string $browserName): Collection * * @param array $items */ - public function saveRelated(array|Collection $items, string $browserName): void + public function saveRelated(array|Collection|Model $items, string $browserName): void { + $items = collect($items); + /** @var Collection $itemsToProcess */ $itemsToProcess = $this->relatedItems()->where('browser_name', $browserName)->get(); diff --git a/tests/integration/Controllers/Tables/BrowserColumnTest.php b/tests/integration/Controllers/Tables/BrowserColumnTest.php index 9046e5b201..f2b95c39b4 100644 --- a/tests/integration/Controllers/Tables/BrowserColumnTest.php +++ b/tests/integration/Controllers/Tables/BrowserColumnTest.php @@ -27,12 +27,7 @@ public function testWithSingleValue(): void $category = $this->createCategory(); $this->author->saveRelated( - [ - [ - 'id' => $category->id, - 'endpointType' => Category::class, - ], - ], + $category, 'categories' ); diff --git a/tests/integration/NplusOneRelatedTest.php b/tests/integration/NplusOneRelatedTest.php index a96fb05c7c..c396917052 100644 --- a/tests/integration/NplusOneRelatedTest.php +++ b/tests/integration/NplusOneRelatedTest.php @@ -35,7 +35,7 @@ public function testSingleRelatedItem(): void 'published' => true, ]); - $storeArray[] = ['endpointType' => Writer::class, 'id' => $writer->id]; + $storeArray[] = $writer; } $letter->saveRelated($storeArray, 'dummyBrowser');