Link table column to relation

Is there an easier way of linking a table column to the relation page? Or is this the way?
Tables\Columns\TextColumn::make('entity.name')
->searchable()
->url(fn (User $record): ?string => $record->entity ? EntityResource::getUrl('edit', ['record' => $record->entity]) : null),
Tables\Columns\TextColumn::make('entity.name')
->searchable()
->url(fn (User $record): ?string => $record->entity ? EntityResource::getUrl('edit', ['record' => $record->entity]) : null),
4 Replies
Dan Harrin
Dan Harrin2y ago
correct
Johan
JohanOP2y ago
Thanks Dan! Would be nice to have some handy helper method, ->linkToResource() or something. Is this tried in the past? Otherwise I might look into it when I have time
Dan Harrin
Dan Harrin2y ago
not interested in helper methods as the table builder is not only used with the admin panel we'd end up with leakage between packages i dont think the current 1 line is too bad you can always add a macro to TextColumn if you want it in your project
Johan
JohanOP2y ago
Alright! Thanks anyway!
Want results from more Discord servers?
Add your server