F
Filamentβ€’12mo ago
jaocero

Is it possible to use another relationship if the current relationship is null?

As what the title says, I want to use an alternative relationship if the current is null:
Tables\Columns\TextColumn::make('company.name')
->label('Organization')
->placeholder('No organization')
->searchable()
->sortable()
->wrap(),
Tables\Columns\TextColumn::make('company.name')
->label('Organization')
->placeholder('No organization')
->searchable()
->sortable()
->wrap(),
if the company.name is null then i will use company.external.name
Solution:
You could use something like this. ``` ->getStateUsing(function($record){ Return $record->company->name ?? $record->external->name ?? Null; })...
Jump to solution
2 Replies
Solution
dissto
disstoβ€’12mo ago
You could use something like this. ``` ->getStateUsing(function($record){ Return $record->company->name ?? $record->external->name ?? Null; }) Probably want to add additional checks, but you get the gist 😁
jaocero
jaoceroOPβ€’12mo ago
It worksss thank youuu
Want results from more Discord servers?
Add your server