diff --git a/src/Prettus/Repository/Contracts/RepositoryInterface.php b/src/Prettus/Repository/Contracts/RepositoryInterface.php index 7951d36d..479211c3 100644 --- a/src/Prettus/Repository/Contracts/RepositoryInterface.php +++ b/src/Prettus/Repository/Contracts/RepositoryInterface.php @@ -31,11 +31,13 @@ public function pluck($column, $key = null); /** * Sync relations * + * @param $id * @param $relation * @param array $attributes - * @return $this + * @param boolean $detaching + * @return array */ - public function sync($relation, $attributes); + public function sync($id, $relation, $attributes, $detaching = true); /** * Retrieve all data of repository diff --git a/src/Prettus/Repository/Eloquent/BaseRepository.php b/src/Prettus/Repository/Eloquent/BaseRepository.php index 1ce572c5..140e2c33 100644 --- a/src/Prettus/Repository/Eloquent/BaseRepository.php +++ b/src/Prettus/Repository/Eloquent/BaseRepository.php @@ -285,14 +285,15 @@ public function pluck($column, $key = null) /** * Sync relations * + * @param $id * @param $relation * @param array $attributes - * @return $this + * @param boolean $detaching + * @return array */ - public function sync($relation, $attributes) + public function sync($id, $relation, $attributes, $detaching = true) { - $this->model = $this->model->with($relation)->getRelation($relation)->sync($attributes); - return $this; + return $this->find($id)->getRelation($relation)->sync($attributes, $detaching); } /**