© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•15mo ago•
1 reply
Andrew Wallo

Issue with Table Joins in Exports

Hi everyone,

I'm encountering an issue when working with Filament's
modifyQuery
modifyQuery
method for Exports. Specifically, when I try to include table joins or additional query logic (e.g., grouping or calculated columns), the export doesn’t seem to reflect the expected data.

Here’s an example of my
modifyQuery
modifyQuery
implementation:
public static function modifyQuery(Builder $query): Builder
{
    return $query
        ->select('holds.*', 'users.name as created_by_name') // Include basic fields from the hold and joined user
        ->leftJoin('users', 'users.id', '=', 'holds.created_by_id'); // Simple join to get the creator's name
}
public static function modifyQuery(Builder $query): Builder
{
    return $query
        ->select('holds.*', 'users.name as created_by_name') // Include basic fields from the hold and joined user
        ->leftJoin('users', 'users.id', '=', 'holds.created_by_id'); // Simple join to get the creator's name
}


I’ve added the column to the export like this:
ExportColumn::make('created_by_name');
ExportColumn::make('created_by_name');


But when I export, the
created_by_name
created_by_name
column isn’t filled at all. For additional debugging, I added the following:
ExportColumn::make('created_by_name')
    ->getStateUsing(function ($record) {
        ray($record);
    });
ExportColumn::make('created_by_name')
    ->getStateUsing(function ($record) {
        ray($record);
    });


What I noticed:
- The
$record
$record
object only includes data directly from the model/table (e.g.,
holds
holds
), and none of the computed or joined columns (
created_by_name
created_by_name
) are present.
- It seems like the export is only pulling fields defined in the model, ignoring any additional columns from the query.

Context:

- The same logic works perfectly in a Resource table using
getEloquentQuery
getEloquentQuery
, although this doesn't transfer to the export.
- It seems that the
modifyQuery
modifyQuery
method doesn’t affect what data is passed to the export columns.

Does anyone know if there’s a limitation in how
modifyQuery
modifyQuery
interacts with exports? Or am I missing something about how to include computed/joined columns in export data?

I’d appreciate any advice or insight on how to resolve this!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

exports table csv
FilamentFFilament / ❓┊help
2y ago
Column not found with table filter and joins
FilamentFFilament / ❓┊help
2y ago
Issue with reordable table
FilamentFFilament / ❓┊help
15mo ago
Exports
FilamentFFilament / ❓┊help
2y ago