Skip to content

Commit 8eed3e8

Browse files
authored
Merge pull request #3229 from Seb33300/filter-callback
feat: add relation resolver param to filter callbacks
2 parents 9e6b686 + 11c7107 commit 8eed3e8

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/EloquentDataTable.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ protected function isMorphRelation($relation)
155155
}
156156

157157
/**
158-
* Resolve the proper column name be used.
159-
*
158+
* {@inheritDoc}
160159
*
161160
* @throws \Yajra\DataTables\Exceptions\Exception
162161
*/

src/QueryDataTable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ protected function applyFilterColumn($query, string $columnName, string $keyword
350350
$builder = $this->query->newQuery();
351351
}
352352

353-
$callback($builder, $keyword);
353+
$callback($builder, $keyword, fn ($column) => $this->resolveRelationColumn($column));
354354

355355
/** @var \Illuminate\Database\Query\Builder $baseQueryBuilder */
356356
$baseQueryBuilder = $this->getBaseQueryBuilder($builder);
@@ -384,7 +384,7 @@ public function getQuery(): QueryBuilder
384384
}
385385

386386
/**
387-
* Resolve the proper column name be used.
387+
* Resolve the proper column name to be used.
388388
*/
389389
protected function resolveRelationColumn(string $column): string
390390
{
@@ -646,7 +646,7 @@ protected function searchPanesSearch(): void
646646
*/
647647
protected function resolveCallbackParameter(): array
648648
{
649-
return [$this->query, $this->scoutSearched];
649+
return [$this->query, $this->scoutSearched, fn ($column) => $this->resolveRelationColumn($column)];
650650
}
651651

652652
/**

0 commit comments

Comments
 (0)