legalworks/laravel-logged-values

Ever needed to store simple values easily, that could change over time or even in the future? When Event Sourcing is just a bit too much?

v0.0.5 2020-10-27 19:18 UTC

This package is auto-updated.

Last update: 2024-12-18 05:02:36 UTC


README

Latest Version on Packagist Total Downloads License

Ever needed to store simple values easily, that could change over time or even in the future? When Event Sourcing is just a bit too much? This is for you... maybe.

Installation

Via Composer

$ composer require legalworks/laravel-logged-values

Usage

Add trait

use Legalworks\LoggedValues\HasLoggedValues;

class SomeModel extends Model{
    use HasLoggedValues;
    ...
}

Add any logged values

$someModel->logValue('pages', 500, [
    'effective_at' => now(), //optional, defaults to now()
    'description' => null, //optional
]);

Get logged values

$someModel->loggedValues; //all logged values
$someModel->groupedValues; //all values grouped by key
$someModel->pastValues;
$someModel->futureValues;

$someModel->getLatestValue('pages', '2020-10-27 12:00:00'); //get the latest value of the given key before given (optional) datetime

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.