Okipa / laravel-table

Generate tables from Eloquent models.
MIT License
532 stars 64 forks source link

Suggestion: Allow diffForHumans for dateTimeFormat #72

Closed tomcrofty closed 2 years ago

tomcrofty commented 3 years ago

diffForHumans() is a function of a Carbon DateTime object, with the current dateTimeFormat() function we can only use traditional PHP date formatting methods. This implementation would be really fantastic.

Loving this package, thanks a bunch :D

tomcrofty commented 3 years ago

For anyone wondering, the current best implementation is to edit the value of the column, like below:

$table->column('next_bill')->value(function(User $user) {
    return $user->next_bill->diffForHumans();
})->sortable()->title('Next Bill');
Okipa commented 3 years ago

Hi @tomcrofty, thanks for the proposal, I would accept a tested PR for this addition 👍🏻

Okipa commented 2 years ago

Closing this as creating formatters is a feature that will be available in V5.