Skip to content

Commit

Permalink
Fix sync, added aplyscope findWhereIn and findWhereNotInt
Browse files Browse the repository at this point in the history
  • Loading branch information
eullercdr committed Mar 9, 2017
1 parent 1363f76 commit baa74a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Prettus/Repository/Contracts/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ public function pluck($column, $key = null);
/**
* Sync relations
*
* @param $id
* @param $relation
* @param array $attributes
* @return $this
*/
public function sync($id, $relation, $attributes);
public function sync($relation, $attributes);

/**
* Retrieve all data of repository
Expand Down
5 changes: 3 additions & 2 deletions src/Prettus/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,11 @@ public function pluck($column, $key = null)
/**
* Sync relations
*
* @param $id
* @param $relation
* @param array $attributes
* @return $this
*/
public function sync($id, $relation, $attributes)
public function sync($relation, $attributes)
{
$this->model = $this->model->with($relation)->getRelation($relation)->sync($attributes);
return $this;
Expand Down Expand Up @@ -444,6 +443,7 @@ public function findWhere(array $where, $columns = ['*'])
public function findWhereIn($field, array $values, $columns = ['*'])
{
$this->applyCriteria();
$this->applyScope();
$model = $this->model->whereIn($field, $values)->get($columns);
$this->resetModel();

Expand All @@ -462,6 +462,7 @@ public function findWhereIn($field, array $values, $columns = ['*'])
public function findWhereNotIn($field, array $values, $columns = ['*'])
{
$this->applyCriteria();
$this->applyScope();
$model = $this->model->whereNotIn($field, $values)->get($columns);
$this->resetModel();

Expand Down

0 comments on commit baa74a8

Please sign in to comment.