From a6c681db39d6ba5b915c96a3229c20cadee14b83 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 17 Oct 2012 18:27:35 +0300 Subject: [PATCH] Make sure sync() always works with arrays. --- .../database/eloquent/relationships/has_many_and_belongs_to.php | 1 + 1 file changed, 1 insertion(+) diff --git a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php index 1c0d3e03..ee37ca2e 100644 --- a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php +++ b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php @@ -121,6 +121,7 @@ public function detach($ids) public function sync($ids) { $current = $this->pivot()->lists($this->other_key()); + $ids = (array) $ids; // First we need to attach any of the associated models that are not currently // in the joining table. We'll spin through the given IDs, checking to see