|
2 | 2 |
|
3 | 3 | namespace Spatie\QueryBuilder; |
4 | 4 |
|
| 5 | +use Illuminate\Support\Str; |
5 | 6 | use Illuminate\Http\Request; |
6 | 7 | use Illuminate\Support\Collection; |
7 | 8 | use Illuminate\Database\Eloquent\Builder; |
@@ -86,7 +87,7 @@ public function allowedFields($fields): self |
86 | 87 |
|
87 | 88 | $this->allowedFields = collect($fields) |
88 | 89 | ->map(function (string $fieldName) { |
89 | | - if (! str_contains($fieldName, '.')) { |
| 90 | + if (! Str::contains($fieldName, '.')) { |
90 | 91 | $modelTableName = $this->getModel()->getTable(); |
91 | 92 |
|
92 | 93 | return "{$modelTableName}.{$fieldName}"; |
@@ -360,14 +361,14 @@ protected function addAppendsToResults(Collection $results) |
360 | 361 | protected function addIncludesToQuery(Collection $includes) |
361 | 362 | { |
362 | 363 | $includes |
363 | | - ->map('camel_case') |
| 364 | + ->map([Str::class, 'camel']) |
364 | 365 | ->map(function (string $include) { |
365 | 366 | return collect(explode('.', $include)); |
366 | 367 | }) |
367 | 368 | ->flatMap(function (Collection $relatedTables) { |
368 | 369 | return $relatedTables |
369 | 370 | ->mapWithKeys(function ($table, $key) use ($relatedTables) { |
370 | | - $fields = $this->getFieldsForIncludedTable(snake_case($table)); |
| 371 | + $fields = $this->getFieldsForIncludedTable(Str::snake($table)); |
371 | 372 |
|
372 | 373 | $fullRelationName = $relatedTables->slice(0, $key + 1)->implode('.'); |
373 | 374 |
|
@@ -402,9 +403,9 @@ protected function guardAgainstUnknownFields() |
402 | 403 | { |
403 | 404 | $fields = $this->request->fields() |
404 | 405 | ->map(function ($fields, $model) { |
405 | | - $tableName = snake_case(preg_replace('/-/', '_', $model)); |
| 406 | + $tableName = Str::snake(preg_replace('/-/', '_', $model)); |
406 | 407 |
|
407 | | - $fields = array_map('snake_case', $fields); |
| 408 | + $fields = array_map([Str::class, 'snake'], $fields); |
408 | 409 |
|
409 | 410 | return $this->prependFieldsWithTableName($fields, $tableName); |
410 | 411 | }) |
|
0 commit comments