© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
Kurja

using an accessor as the attribute in a selectFilter in table

Hi, is it possible to use accessor as filters in tables? I'm trying to use an accessor in a SelectFilter and I'm getting the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'publish_status' in 'where clause'

My code is the following

$table->filters([
                SelectFilter::make('status')
                    ->label('Publish status')
                    ->options([
                        'published' => 'published',
                        'scheduled'  => 'scheduled',
                        'draft' => 'draft',
                    ])
                    ->attribute('publish_status'),
            ])
$table->filters([
                SelectFilter::make('status')
                    ->label('Publish status')
                    ->options([
                        'published' => 'published',
                        'scheduled'  => 'scheduled',
                        'draft' => 'draft',
                    ])
                    ->attribute('publish_status'),
            ])


And the accesor in the model is the following

public function publishStatus(): Attribute
    {
        return Attribute::make(
            get: function() {
                if ($this->published_at) {
                    return 'published';
                }

                if ($this->scheduled_at) {
                    return 'scheduled';
                }

                return 'draft';
            },
        );
    }
public function publishStatus(): Attribute
    {
        return Attribute::make(
            get: function() {
                if ($this->published_at) {
                    return 'published';
                }

                if ($this->scheduled_at) {
                    return 'scheduled';
                }

                return 'draft';
            },
        );
    }


Any help appreciated, thanks in advance
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

Table SelectFilter
FilamentFFilament / ❓┊help
9mo ago
Table SelectFilter
FilamentFFilament / ❓┊help
3y ago
Use attribute from `MorphOne` relationship in a SelectFilter
FilamentFFilament / ❓┊help
3y ago
How to sort the table using model accessor
FilamentFFilament / ❓┊help
2y ago