Skip to content

feat: add relation resolver param to filter callbacks #3229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

Seb33300
Copy link
Contributor

@Seb33300 Seb33300 commented Apr 22, 2025

Alternative to #3228

Not sure which implementation is better, I will let you choose what you prefer.

I would like to suggest to add resolveRelationColumn() as new param to the filter callbacks:

$datatable = new EloquentDataTable($query);

$datatable
    ->filter(function ($query, $scoutSearch, $resolver) {
        // $resolver automatically create joins if needed
        $query->where($resolver('foo.bar'), 'xxx');
    })
    ->filterColumn('foo.bar', function ($query, $keyword, $resolver) {
        // $resolver automatically create joins if needed
        $query->where($resolver('foo.bar'), 'xxx');
    })
;

@yajra
Copy link
Owner

yajra commented Apr 28, 2025

I like the resolver idea, thanks!

@yajra yajra merged commit 8eed3e8 into yajra:master Apr 28, 2025
6 of 7 checks passed
@yajra
Copy link
Owner

yajra commented Apr 28, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants