F
Filamentβ€’6mo ago
dyo

Problem with formatStateUsing in TextColumn of custom table attribute

I just upgrading filament v2 to v3, but I got issue in textcolumn class with formatStateUsing method..
Tables\Columns\TextColumn::make('qty')->formatStateUsing(function ($record) {
$qty = Konfirmasi::where('trans_ref', $record->id)->sukses()->count();
return number_format($qty, 0);
}),
Tables\Columns\TextColumn::make('qty')->formatStateUsing(function ($record) {
$qty = Konfirmasi::where('trans_ref', $record->id)->sukses()->count();
return number_format($qty, 0);
}),
The qty attribute is not in table schema.. I need extra column to show the custom query.. In v2, the code above is working, but in v3, the column is returned blank.. What should I do to make it work in v3?
6 Replies
Vp
Vpβ€’6mo ago
Check the column which is available in the table, eg: make('updated_at')->label('Qty')->formatState...
Vp
Vpβ€’6mo ago
It looks like you display the count of sukses() relationship.. so suggest you to checkout Relationship column https://filamentphp.com/docs/3.x/tables/columns/relationships
dyo
dyoOPβ€’6mo ago
What if need more custom state column but I already used all available table column?
Vp
Vpβ€’6mo ago
I already suggested most of the options
dyo
dyoOPβ€’6mo ago
thanks for your suggestions πŸ‘
Want results from more Discord servers?
Add your server