Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisdicarlo/eloquent-human-timestamps
Automatic human timestamps for Laravel Eloquent models.
https://github.com/chrisdicarlo/eloquent-human-timestamps
eloquent laravel timestamp
Last synced: 3 months ago
JSON representation
Automatic human timestamps for Laravel Eloquent models.
- Host: GitHub
- URL: https://github.com/chrisdicarlo/eloquent-human-timestamps
- Owner: chrisdicarlo
- License: mit
- Created: 2020-10-15T22:23:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-13T12:38:15.000Z (almost 2 years ago)
- Last Synced: 2024-10-13T08:43:44.930Z (3 months ago)
- Topics: eloquent, laravel, timestamp
- Language: PHP
- Homepage:
- Size: 70.3 KB
- Stars: 36
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
README
# Automatic human timestamp properties in Laravel
This package provides a trait you can add to an Eloquent model that will automatically create human-readable timestamp diffs using Carbon.
[![Latest Version on Packagist](https://img.shields.io/packagist/v/chrisdicarlo/eloquent-human-timestamps.svg?style=flat-square)](https://packagist.org/packages/chrisdicarlo/eloquent-human-timestamps)
![Laravel 7/8 Tests](https://github.com/chrisdicarlo/eloquent-human-timestamps/actions/workflows/run-tests-L7.yml/badge.svg)
![Laravel 9 Tests](https://github.com/chrisdicarlo/eloquent-human-timestamps/actions/workflows/run-tests-L9.yml/badge.svg)
![Laravel 10 Tests](https://github.com/chrisdicarlo/eloquent-human-timestamps/actions/workflows/run-tests-L10.yml/badge.svg)
[![Total Downloads](https://img.shields.io/packagist/dt/chrisdicarlo/eloquent-human-timestamps.svg?style=flat-square)](https://packagist.org/packages/chrisdicarlo/eloquent-human-timestamps)## Version Compatibility
| Laravel | PHP | Package Version |
| ------- | --- | --------------- |
| 6 | 8.0, 7.4, 7.3 | 2 |
| 7 | 8.0, 7.4, 7.3 | 2 |
| 8 | 8.1, 8.0, 7.4, 7.3 | 3 |
| 9 | 8.1, 8.0 | 4 |
| 10 | 8.1 | 5 |## 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.