FilamentF
Filament2y ago
jeph

two columns from a single database column

Hello everyone!

Before in v2, I can create two columns from a single database column. But now in v3, when I create a second column from the same database column, the first column will be replaced by the 2nd column. Is there a way to make two columns out of the same database column now in v3?

Sample code:

TextColumn::make('name')
    ->formatStateUsing(function ($state) {
        $names = explode(' ', $state); // Split the full name into an array
        return $names[0]; // First name
    })
    ->label('First Name'),

TextColumn::make('name')
    ->formatStateUsing(function ($state) {
        $names = explode(' ', $state); // Split the full name into an array
        return $names[1] ?? ''; // Last name (or empty string if not available)
    })
    ->label('Last Name'),
Was this page helpful?