© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
5 replies
Daniele

Multiple columns from the same relationship in an ExportAction

Heya everyone!
I am trying to create an export, and I need to get two columns computed aggregating the same relationship, with a different scope.

For example:
User has a relationship with Post (1:N).
Post has a type field that can either be 'video' or 'image'.
In my User export, I'd like to have two columns "has videos" and "has images".

I can do one just fine doing something like
ExportColumn::make('posts_exists')
  ->exists(['posts' => fn (Builder $query) => $query->where('type', 'video')])
  ->label('Has videos')
ExportColumn::make('posts_exists')
  ->exists(['posts' => fn (Builder $query) => $query->where('type', 'video')])
  ->label('Has videos')

But if I try to add another for the images I need to use the same column name (
posts_exists
posts_exists
) and it breaks.
Is there any way to get it done?

For now I've resorted to creating two "scoped" relationships, but I'd like to avoid it if possible.
Solution
In the end I went with the custom relationships, I only had two so it was not that bad.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Count same relationship in multiple columns
FilamentFFilament / ❓┊help
2y ago
Import CSV multiple columns in one relationship
FilamentFFilament / ❓┊help
17mo ago
Multiple columns of same attribute
FilamentFFilament / ❓┊help
3y ago
Table ExportAction failing on relationship
FilamentFFilament / ❓┊help
2y ago