Skip to content

Commit 876d510

Browse files
committed
Remove ability to exclude global scopes
1 parent 65634c0 commit 876d510

4 files changed

Lines changed: 0 additions & 42 deletions

File tree

docs/_sidebar.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
- Scopes
1212
- [Quick start](scopes.md?id=scopes)
1313
- [Usage](scopes.md?id=usage)
14-
- [Remove Global Scopes](scopes.md?id=remove-global-scopes)
1514

1615
- Appends
1716
- [Quick start](appends.md?id=appends)

docs/scopes.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,4 @@ The following query parameter will add the `popular` scope:
88

99
```url
1010
{base_url}/users?scope[]=popular
11-
```
12-
13-
# Remove Global Scopes
14-
15-
Global scopes allow you to add constraints to all queries for a given model.
16-
What if we want to remove it ?
17-
18-
The following query parameter will remove the `delivered` global scope:
19-
20-
```url
21-
{base_url}/books?excludeGlobalScopes[]=delivered
2211
```

src/Controllers/LaravelController.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,6 @@ protected function parseWithCount(array $withCounts)
216216
return $return;
217217
}
218218

219-
/**
220-
* Parse excludeGlobalScopes into resource.
221-
*
222-
* @param array $excludeGlobalScopes
223-
*
224-
* @return array
225-
*/
226-
protected function parseExcludeGlobalScopes(array $excludeGlobalScopes)
227-
{
228-
$return = [];
229-
230-
foreach ($excludeGlobalScopes as $exludeGlobalScope) {
231-
$return[] = $exludeGlobalScope;
232-
}
233-
234-
return $return;
235-
}
236-
237219
/**
238220
* Parse filters.
239221
*
@@ -367,7 +349,6 @@ protected function parseResourceOptions($request = null)
367349
'withs' => [],
368350
'has' => [],
369351
'doesntHave' => [],
370-
'excludeGlobalScopes' => [],
371352
'scope' => [],
372353
'sort' => [],
373354
'limit' => null,
@@ -392,7 +373,6 @@ protected function parseResourceOptions($request = null)
392373
$withs = $request->get('with', $this->defaults['withs']);
393374
$has = $request->get('has', $this->defaults['has']);
394375
$doesntHave = $request->get('doesntHave', $this->defaults['doesntHave']);
395-
$excludeGlobalScopes = $this->parseExcludeGlobalScopes($request->get('excludeGlobalScopes', $this->defaults['excludeGlobalScopes']));
396376
$scope = $request->get('scope', $this->defaults['scope']);
397377
$sort = $this->parseSort($request->get('sort', $this->defaults['sort']));
398378
$limit = $request->get('limit', $this->defaults['limit']);
@@ -415,7 +395,6 @@ protected function parseResourceOptions($request = null)
415395
'withs' => $withs,
416396
'has' => $has,
417397
'doesntHave' => $doesntHave,
418-
'excludeGlobalScopes' => $excludeGlobalScopes,
419398
'modes' => $modes,
420399
'scope' => $scope,
421400
'sort' => $sort,

src/Database/EloquentBuilderTrait.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ protected function applyResourceOptions(Builder $queryBuilder, array $options =
6969
}
7070
}
7171

72-
if (isset($excludeGlobalScopes)) {
73-
$this->applyWithouGlobalScopes($queryBuilder, $excludeGlobalScopes);
74-
}
75-
7672
if (isset($filter_groups)) {
7773
$this->applyFilterGroups($queryBuilder, $filter_groups);
7874
}
@@ -158,11 +154,6 @@ protected function applySortByDesc(Builder $queryBuilder, array $sortByDesc = []
158154
}
159155
}
160156

161-
protected function applyWithouGlobalScopes(Builder $queryBuilder, array $excludeGlobalScopes = [])
162-
{
163-
$queryBuilder->withoutGlobalScopes($excludeGlobalScopes);
164-
}
165-
166157
protected function applyFilter(Builder $queryBuilder, array $filter, $or = false)
167158
{
168159
$column = $filter['column'];

0 commit comments

Comments
 (0)