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:
My code is the following
And the accesor in the model is the following
Any help appreciated, thanks in advance
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'),
])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';
},
);
}Any help appreciated, thanks in advance