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(),

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;
})

Probably want to add additional checks, but you get the gist 😁
Was this page helpful?