Closed aliloubm closed 2 years ago
filament/filament
v2.6.3
v8
v2
PHP 8
If i use custom attribute in my model :
Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fullname' in 'order clause' (SQL: select * from `bulletin` order by `fullname` asc limit 10 offset 0) (View: /xxx/vendor/filament/tables/resources/views/index.blade.php)
I have a custom attribute in a model
public function getFullnameAttribute() { return "$this->name - ".($this->datadate)->formatLocalized('%B %Y'); }
and in ressource page
public static function table(Table $table): Table { return $table ->columns([ // Tables\Columns\TextColumn::make('fullname')->sortable()->label('Titre'), Tables\Columns\TextColumn::make('datadate')->date('m/Y')->sortable()->label('Date'), Tables\Columns\BooleanColumn::make('published')->label('Publié') ->trueIcon('heroicon-o-check-circle') ->falseIcon('heroicon-o-x-circle') ]) ->filters([ // ]); }
No response
Hey, you need to pass the column names to sort to the sortable() method: sortable(['name']).
sortable()
sortable(['name'])
thx,
sortable(['name','datadate']) work perfectly as intended
sortable(['name','datadate'])
Package
filament/filament
Package Version
v2.6.3
Laravel Version
v8
Livewire Version
v2
PHP Version
PHP 8
Bug description
If i use custom attribute in my model :
Steps to reproduce
I have a custom attribute in a model
and in ressource page
Relevant log output
No response