Download the PHP package amrachraf6699/datify without Composer
On this page you can find all versions of the php package amrachraf6699/datify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amrachraf6699/datify
More information about amrachraf6699/datify
Files in amrachraf6699/datify
Package datify
Short Description Automatic timestamp formatting helpers for Laravel created_at and updated_at columns.
License MIT
Informations about the package datify
Datify for Laravel
Datify auto-formats created_at and updated_at across your Laravel models. Set a default display for each column, opt into extra variants (humanized, ISO, calendar, etc.), and customize the attribute naming pattern—all via a single config file.
Why Datify?
- Consistent timestamp output without repeating
format()everywhere. - Drop-in trait: add to a base model to cover the whole project.
- Config-driven: toggle variants, set defaults per column, change attribute suffixes, or supply a custom PHP date format.
Requirements
- PHP 8.0+
- Laravel 8-12 (illuminate/support, illuminate/database) — including Laravel 12
Installation
Quick Start
Add the trait to your base model (or any model you want to opt in):
Configuration (config/datify.php)
Key options (see inline comments in the config for details):
- Boolean toggles:
to_date,to_time,to_date_time,to_day_date_time,to_iso_8601,to_iso,to_human,to_short_human,to_calendar. custom: PHP date format string used whencustomis selected; ifnull, raw DB timestamp is returned.suffix: naming pattern for appended attributes;{format}becomes the format key withoutto_. Default_{format}yieldscreated_at_human,updated_at_iso_8601, etc.defaults: per-column default format forcreated_atandupdated_atwhen you access them normally.
Example Config
Attribute Outputs
- Base attributes (
created_at,updated_at): formatted usingdefaults.created_at/defaults.updated_at. - Extra attributes: added only when the corresponding boolean toggle is
true. Names followsuffixwith{format}substituted (format key withoutto_).
Example Model Output
Given created_at = 2024-12-28 13:37:42 UTC, config with suffix: '_{format}', to_human: true, to_iso_8601: true, defaults.created_at: 'to_date_time':
Using a Custom Format Default
Raw Database Values
- Use
$model->getRawOriginal('created_at')or->getRawOriginal('updated_at')to bypass formatting. - If
customis selected as the default andcustomisnull, Datify falls back to the raw DB timestamp string (e.g.,Y-m-d H:i:s).
Integration Tips
- Add the trait to your base model to cover all models at once.
- Choose minimal toggles to avoid bloating serialized output; only enable the variants you need.
- When changing the
suffix, remember it affects all appended attribute names; update API consumers accordingly.
Changelog & Contributing
- Open a PR or issue at https://github.com/amrachraf6699/Datify once the repo is live.
- Please include Laravel/PHP versions and a reproduction snippet when filing bugs.
All versions of datify with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^8.0|^9.0|^10.0|^11.0|^12.0