© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
SeatSwitchER

How to filter table results based on related table field?

Hello everyone. I have a table with orders, each order have payment [cash or credit card], I want to filter orders which have cash or credit card.

Orders Model have relation to Payments Model:

public function payments(): HasOne
{
    return $this->hasOne(RkPayments::class, 'VISIT', 'VISIT');
}
public function payments(): HasOne
{
    return $this->hasOne(RkPayments::class, 'VISIT', 'VISIT');
}


Here is column in $table:

IconColumn::make('payments.PAYLINETYPE')
    ->icon(fn (string $state): string => match ($state) {
        '1' => 'heroicon-o-credit-card',
        '0' => 'heroicon-o-banknotes',
    })->color(fn (string $state): string => match ($state) {
        '0' => 'success',
        '1' => 'warning',
        default => 'gray',
    })->label('Payment type'),
IconColumn::make('payments.PAYLINETYPE')
    ->icon(fn (string $state): string => match ($state) {
        '1' => 'heroicon-o-credit-card',
        '0' => 'heroicon-o-banknotes',
    })->color(fn (string $state): string => match ($state) {
        '0' => 'success',
        '1' => 'warning',
        default => 'gray',
    })->label('Payment type'),


Here is filter:

SelectFilter::make('payType')->label('Payment type')->options([
    '1' => 'Bank card',
    '0' => 'Cash'
])->relationship('payments', 'PAYLINETYPE')->attribute('payments.PAYLINETYPE'),
SelectFilter::make('payType')->label('Payment type')->options([
    '1' => 'Bank card',
    '0' => 'Cash'
])->relationship('payments', 'PAYLINETYPE')->attribute('payments.PAYLINETYPE'),


When I use this filter, I get PHP error Our of memory. Can't get it clear, how to check what query it builds... Any ideas?
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

How to filter table based on grandparent relationships?
FilamentFFilament / ❓┊help
3y ago
widget query filter on related field
FilamentFFilament / ❓┊help
2y ago
How to Show the Relationship based table field based on dropdown selection
FilamentFFilament / ❓┊help
2y ago
filter table data based on external API
FilamentFFilament / ❓┊help
3y ago