Add condition if column value blank in table

In Resource I have a form with label 'Download Url' the field is not manditory. So, when the user doesn't add any value to this field I would like show other field value in place in Table. Any idea on how to achieve it?
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('download_url')->label('Filename')
->formatStateUsing(function($record) {
if($record->download_url != '')
{
return $record->download_url;
}
else
{
return $record->name;
}
}),
Tables\Columns\TextColumn::make('caption'),
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('download_url')->label('Filename')
->formatStateUsing(function($record) {
if($record->download_url != '')
{
return $record->download_url;
}
else
{
return $record->name;
}
}),
Tables\Columns\TextColumn::make('caption'),
No description
Solution:
use state instead of formatStateUsing
Jump to solution
3 Replies
Want results from more Discord servers?
Add your server