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
Dan Harrin
Dan Harrin2y ago
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
CasBizz
CasBizzOP2y ago
So this wouldn't work: class AggrekoLogTable { public static function getAggrekoLogTableColumns(): array { return [ TextColumn::make('aggrekoEquipment.aggrekoEquipmentTypeSpec.title') ->label('Type'), // ->searchable(), // ->sortable(),
Dan Harrin
Dan Harrin2y ago
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
CasBizz
CasBizzOP2y ago
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
Dan Harrin
Dan Harrin2y ago
you have an extra array ->columns(AggrekoLogTable::getAggrekoLogTableColumns()) not ->columns([AggrekoLogTable::getAggrekoLogTableColumns()])
CasBizz
CasBizzOP2y ago
LOL Took me so much time and it is something so simple again hahaha But filament is so nice to have
Dan Harrin
Dan Harrin2y ago
:)
CasBizz
CasBizzOP2y ago
So does this also work with filters and other stuff
Dan Harrin
Dan Harrin2y ago
yes, everything
Want results from more Discord servers?
Add your server