im trying to display a simple TextColumn but nothing shows up

it didnt even dd(). has_uploaded_receipt is not a column name in db, i just want to create a custom one and format based on user relation with receipt.
TextColumn::make('has_uploaded_receipt')
->label('Has uploaded receipt?')
->formatStateUsing( function ($record) {
dd($record);
}),
TextColumn::make('has_uploaded_receipt')
->label('Has uploaded receipt?')
->formatStateUsing( function ($record) {
dd($record);
}),
original code:
TextColumn::make('has_uploaded_receipt')->label('Has uploaded receipt?')->formatStateUsing(fn(User $record): string => $record->receipt() ? "Yes" : "No"),
TextColumn::make('has_uploaded_receipt')->label('Has uploaded receipt?')->formatStateUsing(fn(User $record): string => $record->receipt() ? "Yes" : "No"),
Solution:
nvm, i have solved it using default() instead
Jump to solution
8 Replies
black ka1ser
black ka1serOP5mo ago
No description
yangsystem
yangsystem5mo ago
you should have in the database a cell called has_uploaded_receipt of type boolean (1 or 0) and if you want to alter the color of the field you can do something like ->color(function {if ($has_uploaded_receipt == 1) 'green' else 'danger'}) where success and danger are the color defined in panel config file
black ka1ser
black ka1serOP5mo ago
wait, i thought we can have a custom column without needing a column in table
yangsystem
yangsystem5mo ago
ok here is the doc
Solution
black ka1ser
black ka1ser5mo ago
nvm, i have solved it using default() instead
black ka1ser
black ka1serOP5mo ago
No description
black ka1ser
black ka1serOP5mo ago
No description
Want results from more Discord servers?
Add your server