Table column repetition
Anybody know if there is a way how i can put my table columns in a class to prevent repetition. I have a log table which i use in several locations as relation class what makes it difficult to maintain.
9 Replies
you can put them anywhere you want
return them from a method on the same class, return them from a method on the model, return them from a dedicated class
it doesnt matter
as long as you then call that method inside your columns array, it will work
So this wouldn't work:
class AggrekoLogTable
{
public static function getAggrekoLogTableColumns(): array
{
return [
TextColumn::make('aggrekoEquipment.aggrekoEquipmentTypeSpec.title')
->label('Type'),
// ->searchable(),
// ->sortable(),
where are you using that
also, if its a relation manager, you dont even need more than one relation manager class. it can be reused between resources
public static function table(Table $table): Table
{
return $table
->columns([
AggrekoLogTable::getAggrekoLogTableColumns()
Just like i use with the forms. But i think i missing the clue
you have an extra array
->columns(AggrekoLogTable::getAggrekoLogTableColumns())
not ->columns([AggrekoLogTable::getAggrekoLogTableColumns()])
LOL
Took me so much time and it is something so simple again hahaha
But filament is so nice to have
:)
So does this also work with filters and other stuff
yes, everything