Skip to content

Commit 4fb4268

Browse files
committed
♻️ review requested
1 parent 968ac1b commit 4fb4268

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

config/orion.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,19 @@
3434
],
3535
'search' => [
3636
'case_sensitive' => true, // TODO: set to "false" by default in 3.0 release
37+
/*
38+
|--------------------------------------------------------------------------
39+
| Max Nested Depth
40+
|--------------------------------------------------------------------------
41+
|
42+
| This value is the maximum depth of nested filters
43+
| you will most likely need this to be maximum at 1 but
44+
| you can increase this number if necessary. Please
45+
| be aware that the depth generate dynamic rules and can slow
46+
| your application if someone sends a request with thousands of nested
47+
| filters.
48+
|
49+
*/
50+
'max_nested_depth' => 1
3751
],
38-
39-
/*
40-
|--------------------------------------------------------------------------
41-
| Max Nested Depth
42-
|--------------------------------------------------------------------------
43-
|
44-
| This value is the maximum depth of nested filters
45-
| you will most likely need this to be maximum at 1 but
46-
| you can increase this number if necessary. Please
47-
| be aware that the depth generate dynamic rules and can slow
48-
| your application if someone sends a request with thousands of nested
49-
| filters.
50-
|
51-
*/
52-
'max_nested_depth' => 1
5352
];

src/Drivers/Standard/ParamsValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function validateFilters(Request $request): void
4949
{
5050
$max_depth = ceil(($this->getArrayDepth($request->all()['filters'])) / 2) - 1;
5151

52-
abort_if($max_depth > config('orion.max_nested_depth'), 422, __('Max nested depth :depth is exceeded', ['depth' => config('orion.max_nested_depth')]));
52+
abort_if($max_depth > config('orion.search.max_nested_depth'), 422, __('Max nested depth :depth is exceeded', ['depth' => config('orion.search.max_nested_depth')]));
5353

5454
Validator::make(
5555
$request->all(),

tests/Feature/StandardIndexNestedFilteringOperationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ public function getting_a_list_of_resources_nested_filtered_by_not_whitelisted_f
111111
);
112112

113113
$response->assertStatus(422);
114-
$response->assertJsonStructure(['message', 'errors' => ['field']]);
114+
$response->assertJsonStructure(['message', 'errors' => ['filters.0.nested.0.field']]);
115115
}
116116
}

tests/Fixtures/app/Providers/OrionServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public function boot()
4545
{
4646
app()->make(Kernel::class)->pushMiddleware(EnforceExpectsJson::class);
4747

48+
$this->mergeConfigFrom(__DIR__ . '/../../../../config/orion.php', 'orion');
49+
4850
$this->loadRoutesFrom(__DIR__.'/../../routes/api.php');
4951
}
5052
}

0 commit comments

Comments
 (0)