Skip to content

Commit 5ad582e

Browse files
cristijoragithub-actions[bot]
authored andcommitted
Fix styling
1 parent 79d8803 commit 5ad582e

File tree

4 files changed

+114
-119
lines changed

4 files changed

+114
-119
lines changed

src/Filters/SearchableFilter.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,32 @@ protected function applyJoinSearchConditions($query, $likeOperator, $value)
6363
$relatedModel = $this->belongsToField->getRelatedModel($this->repository);
6464
$relatedTable = $relatedModel->getTable();
6565
$parentTable = $this->repository->model()->getTable();
66-
66+
6767
$localKey = $this->belongsToField->getQualifiedKey($this->repository);
6868
$foreignKeyName = $relatedModel->getKeyName();
69-
69+
7070
// Use a consistent alias based on the relationship name to reuse joins
7171
$relationshipName = $this->belongsToField->getAttribute();
7272
$joinAlias = "{$relatedTable}_for_{$relationshipName}";
73-
73+
7474
// Check if this exact join already exists
7575
$existingJoins = collect($query->getQuery()->joins ?? []);
7676
$joinExists = $existingJoins->contains(function ($join) use ($joinAlias, $relatedTable) {
77-
return $join->table === "{$relatedTable} as {$joinAlias}" ||
77+
return $join->table === "{$relatedTable} as {$joinAlias}" ||
7878
str_contains($join->table, $joinAlias);
7979
});
80-
81-
if (!$joinExists) {
80+
81+
if (! $joinExists) {
8282
$query->leftJoin("{$relatedTable} as {$joinAlias}", function ($join) use ($localKey, $joinAlias, $foreignKeyName) {
8383
$join->on($localKey, '=', "{$joinAlias}.{$foreignKeyName}");
8484
});
8585
}
86-
86+
8787
// Apply search conditions for each searchable attribute
8888
collect($this->belongsToField->getSearchables())->each(function (string $attribute) use ($query, $likeOperator, $value, $joinAlias) {
8989
$qualifiedAttribute = "{$joinAlias}.{$attribute}";
90-
91-
if (!config('restify.search.case_sensitive')) {
90+
91+
if (! config('restify.search.case_sensitive')) {
9292
$upper = strtoupper($value);
9393
$query->orWhereRaw("UPPER({$qualifiedAttribute}) LIKE ?", ['%'.$upper.'%']);
9494
} else {
@@ -113,5 +113,4 @@ protected function applySubquerySearchConditions($query, $likeOperator, $value)
113113
);
114114
});
115115
}
116-
117116
}

src/Services/Search/RepositorySearchService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ public function prepareRelations(RestifyRequest $request, Builder|Relation $quer
116116
})->all();
117117

118118
$eagerRelations = array_merge($filtered, ($this->repository)::withs());
119-
119+
120120
// Only exclude joined relationships if JOIN optimization is enabled
121121
if (config('restify.search.use_joins', false)) {
122122
$joinedRelations = $this->getJoinedRelationships($query);
123123
$eagerRelations = array_diff($eagerRelations, $joinedRelations);
124124
}
125-
125+
126126
return $query->with($eagerRelations);
127127
}
128128

@@ -254,15 +254,15 @@ protected function getJoinedRelationships($query): array
254254
{
255255
$joinedRelations = [];
256256
$joins = collect($query->getQuery()->joins ?? []);
257-
257+
258258
// Extract relationship names from join aliases
259259
$joins->each(function ($join) use (&$joinedRelations) {
260260
if (str_contains($join->table, '_for_')) {
261261
$relationName = str($join->table)->after('_for_')->toString();
262262
$joinedRelations[] = $relationName;
263263
}
264264
});
265-
265+
266266
return $joinedRelations;
267267
}
268268

0 commit comments

Comments
 (0)