项目作者: chrisdicarlo

项目描述 :
Automatic human timestamps for Laravel Eloquent models.
高级语言: PHP
项目地址: git://github.com/chrisdicarlo/eloquent-human-timestamps.git
创建时间: 2020-10-15T22:23:43Z
项目社区:https://github.com/chrisdicarlo/eloquent-human-timestamps

开源协议:MIT License

下载


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
Laravel 7/8 Tests
Laravel 9 Tests
Laravel 10 Tests
Laravel 11 Tests
Total Downloads

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, 8.2, 8.3, 8.4 5
11 8.2, 8.3, 8.4 6

Installation

To install the package run:

  1. composer require chrisdicarlo/eloquent-human-timestamps

Setup

Add the ChrisDiCarlo\EloquentHumanTimestamps\HumanTimestamps trait to a model that has timestamp columns, e.g.:

  1. use ChrisDiCarlo\EloquentHumanTimestamps\HumanTimestamps;
  2. class Foobar
  3. {
  4. use HumanTimestamps;
  5. ...
  6. }

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.