chrisdicarlo / eloquent-human-timestamps
Installs: 3 180
Dependents: 0
Suggesters: 0
Security: 0
Stars: 36
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^7.3|^8.0
- illuminate/support: ^7.0|^8.0|^9.0|^10
Requires (Dev)
- orchestra/testbench: ^5.0|^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.4|^9.5.4
README
This package provides a trait you can add to an Eloquent model that will automatically create human-readable timestamp diffs using Carbon.
Version Compatibility
Installation
To install the package run:
composer require chrisdicarlo/eloquent-human-timestamps
Setup
Add the ChrisDiCarlo\EloquentHumanTimestamps\HumanTimestamps trait to a model that has timestamp columns, e.g.:
use ChrisDiCarlo\EloquentHumanTimestamps\HumanTimestamps;
class Foobar
{
use HumanTimestamps;
...
}
Usage
To get the human-readable attribute, simply retrieve the timestamp normally but append _for_humans to the name, e.g. created_at_for_humans, updated_at_for_humans.