Skip to content

Commit

Permalink
Fixed Sync, added syncWithoutDetaching
Browse files Browse the repository at this point in the history
  • Loading branch information
eullercdr committed Mar 9, 2017
1 parent bf1f3b1 commit 2331634
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/Prettus/Repository/Contracts/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ public function pluck($column, $key = null);
*
* @param $id
* @param $relation
* @param array $attributes
* @param boolean $detaching
* @return array
* @param $attributes
* @param bool $detaching
* @return mixed
*/
public function sync($id, $relation, $attributes, $detaching = true);

/**
* SyncWithoutDetaching
*
* @param $id
* @param $relation
* @param $attributes
* @return mixed
*/
public function syncWithoutDetaching($id, $relation, $attributes);

/**
* Retrieve all data of repository
*
Expand Down
19 changes: 16 additions & 3 deletions src/Prettus/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,28 @@ public function pluck($column, $key = null)
*
* @param $id
* @param $relation
* @param array $attributes
* @param boolean $detaching
* @return array
* @param $attributes
* @param bool $detaching
* @return mixed
*/
public function sync($id, $relation, $attributes, $detaching = true)
{
return $this->find($id)->getRelation($relation)->sync($attributes, $detaching);
}

/**
* SyncWithoutDetaching
*
* @param $id
* @param $relation
* @param $attributes
* @return mixed
*/
public function syncWithoutDetaching($id, $relation, $attributes)
{
return $this->sync($id, $relation, $attributes, false);
}

/**
* Retrieve all data of repository
*
Expand Down

0 comments on commit 2331634

Please sign in to comment.