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
hayvern10mo ago
How are you feeding data to the column? Using a closure?
03_dotuan
03_dotuanOP10mo 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
lazydog10mo ago
you are in the right path, but dd the value of the record or record->children if it has a value
KeyMe
KeyMe10mo ago
following this thread as well
lazydog
lazydog10mo ago
Or append your new colum from your model, then you can use that appended column in your Table
Dennis Koch
Dennis Koch10mo ago
Use getStateUsing(). formatStateUsing() won't work, because there is no state to format.
03_dotuan
03_dotuanOP10mo ago
Thank you guys, i'll try it
Want results from more Discord servers?
Add your server