0.0
Laravel 11 – 13
PHP 8.3+
The project is in a healthy, maintained state
Eloquent Model History for Laravel
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

phpunit/phpunit
^10.0|^11.0
^9.0|^10.0|^11.0

Runtime

konekt/enum
^3.1|^4.0
^11.46.2|^12.50|^13.0
^11.46.2|^12.50|^13.0
 Project Readme

Eloquent Model History

Tests Packagist version Packagist downloads StyleCI MIT Software License

This package provides features to:

  1. Log changes, diff and comments to Eloquent Models;
  2. Track and log the execution history of Laravel Background Jobs;

Model History

Features:

  • Record model creation, update, delete, and retrieval
  • Add optional comments to events
  • Add comment-only history events
  • Automatically record the IP, URL, user agent and user ids when in an HTTP context
  • Automatically detect the CLI, the command name when in an artisan command
  • Automatically detect the queue and the job when running in a queued job
  • Define included/excluded fields on a per-model basis
  • Has a diff of the changed fields (old/new values)
$task = Task::create(['title' => 'Get milk', 'status' => 'todo']);
History::begin($task);

$task->update(['status' => 'done']);
History::logRecentUpdate($task);

Job History

The goal of tracking a job is to be able to show the status and updates of a background job on frontends. It is similar to logging, but is always scoped to a given job execution, and adds state to each job execution.

Features:

  • Track the execution status of Laravel Jobs
  • Set and read the completion % of a job execution
  • Write logs for job executions
  • Detect the user that has executed the job
class MyJob implements \Konekt\History\Contracts\TrackableJob
{
    use \Konekt\History\Concerns\CanBeTracked;
    
    public function __construct(private array $dataToProcess)
    {        
    }
    
    public function handle()
    {
        $tracker = $this->jobTracker();
        $tracker->setProgressMax(count($this->dataToProcess));
        $tracker->started();
        try {
            foreach ($this->dataToProcess as $data) {
                Do::something()->withThe($data);
                $tracker->advance();
                $tracker->logInfo('An entry was processed');
            }
            $tracker->completed();
        } catch (\Throwable $e) {
            $tracker->failed($e->getMessage());
        }
    }
}

MyJob::dispatch($myDataToProcess);

Requirements

The current version of this package requires PHP 8.3+ and Laravel 11 - 13. PHP 8.1, 8.2 and Laravel 10 are supported in earlier releases.

It has been tested with:

  • PHP 8.1, 8.2, 8.3, 8.4 & 8.5
  • SQLite,
  • MySQL 5.7, 8.0, 8.2 & 8.4,
  • PostgreSQL 12, 15, 16, 17, 18.

It is known that this library, Laravel 11.0/12.0 and PostgreSQL 11 don't work together, therefore it is recommended to use at least Postgres version 12 or higher in case your DB engine is Postgres.

Documentation

For Installation and usage instruction see the Documentation; https://konekt.dev/history/1.x