How to create custom column in the table?

I want to add custom column and its value not related to value of model, i tried by adding TextColumn with custom name but it doesn't show it's value...
8 Replies
hayvern
hayvern5mo ago
How are you feeding data to the column? Using a closure?
03_dotuan
03_dotuan5mo ago
i just using Table and Text Column like this: Tables\Columns\TextColumn::make('main_user_id') ->label('子供数') ->formatStateUsing(fn ($record) => $record->children->count()),
lazydog
lazydog5mo ago
you are in the right path, but dd the value of the record or record->children if it has a value
KeyMe
KeyMe5mo ago
following this thread as well
lazydog
lazydog5mo ago
Or append your new colum from your model, then you can use that appended column in your Table
Dennis Koch
Dennis Koch5mo ago
Use getStateUsing(). formatStateUsing() won't work, because there is no state to format.
03_dotuan
03_dotuan5mo ago
Thank you guys, i'll try it