Skip to content

Commit

Permalink
Adjuste applyScope
Browse files Browse the repository at this point in the history
  • Loading branch information
andersao committed Jul 15, 2015
1 parent 4ca39e6 commit dbf6832
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ php artisan vendor:publish
- with(array $relations);
- hidden(array $fields);
- visible(array $fields);
- scopeQuery(Closure $scope);
- getFieldsSearchable();
- setPresenter($presenter);
- skipPresenter($status = true);
Expand Down Expand Up @@ -318,6 +319,14 @@ $posts = $this->repository->findWhere([
]);
```

Find all using custom scope

```php
$posts = $this->repository->scopeQuery(function($query){
return $query->orderBy('sort_order','asc');
})->all();
```

Create new entry in Repository

```php
Expand Down
7 changes: 2 additions & 5 deletions src/Prettus/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,9 @@ public function skipCriteria($status = true)
*/
protected function applyScope()
{

if ( isset($this->scopeQuery) && is_callable($this->scopeQuery) ) {

$this->model = $this->scopeQuery($this->model);

return $this;
$callback = $this->scopeQuery;
$this->model = $callback($this->model);
}

return $this;
Expand Down

0 comments on commit dbf6832

Please sign in to comment.