Timestamps datatype, applied ->since(), error: Call to a member function since() on string

I have some dates (timestamps data type) that when implementing:
Tables\Columns\TextColumn::make('payment_due_at')
->dateTime('M j, Y')
->description(fn (Booking $record): string => $record->payment_due_at->since()),
Tables\Columns\TextColumn::make('payment_due_at')
->dateTime('M j, Y')
->description(fn (Booking $record): string => $record->payment_due_at->since()),
I get:
Call to a member function since() on string
Call to a member function since() on string
In my model, I have implemented... (found in Laravel docs.)
/**
* The storage format of the model's date columns.
*
* @var string
*/
protected $dateFormat = 'U';


/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'payment_due_at',
'created_at',
'updated_at',
];
/**
* The storage format of the model's date columns.
*
* @var string
*/
protected $dateFormat = 'U';


/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'payment_due_at',
'created_at',
'updated_at',
];
Any suggestions, please? Thank you!
3 Replies
Pablo Torres
Pablo TorresOP2y ago
Doing this works but I have the feeling there must be a FilamentPHP way to do it...
Tables\Columns\TextColumn::make('payment_due_at')
->dateTime('M j, Y')
->description(fn (Booking $record): string => Carbon::parse($record->payment_due_at)->diffForHumans()),
Tables\Columns\TextColumn::make('payment_due_at')
->dateTime('M j, Y')
->description(fn (Booking $record): string => Carbon::parse($record->payment_due_at)->diffForHumans()),
LeandroFerreira
protected $casts = [
'payment_due_at' => 'datetime',
];

...
->description(fn ($record): string => $record->payment_due_at->since())
protected $casts = [
'payment_due_at' => 'datetime',
];

...
->description(fn ($record): string => $record->payment_due_at->since())
?
Pablo Torres
Pablo TorresOP2y ago
@leandro_ferreira as always... thank you so much for your time and patience.
Want results from more Discord servers?
Add your server