Skip to content

Commit

Permalink
fix: allow usage of the main table filtering the fields
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolGoose committed Dec 12, 2024
1 parent beb5862 commit 07ae20d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Concerns/AddsFieldsToQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ protected function addRequestedModelFieldsToQuery(): void
$fields = $fields->mapWithKeys(fn ($fields, $table) => [$table => collect($fields)->map(fn ($field) => Str::snake($field))->toArray()]);
}

$modelFields = $fields->has($modelTableName) ? $fields->get($modelTableName) : $fields->get('_');
// Apply additional table name conversion based on strategy
if (config('query-builder.convert_relation_table_name_strategy', false) === 'camelCase') {
$modelFields = $fields->has(Str::camel($modelTableName)) ? $fields->get(Str::camel($modelTableName)) : $fields->get('_');
} else {
$modelFields = $fields->has($modelTableName) ? $fields->get($modelTableName) : $fields->get('_');
}

if (empty($modelFields)) {
return;
Expand Down

0 comments on commit 07ae20d

Please sign in to comment.