tochka-developers/model-history

Simple history for Laravel models
2,380
Install
composer require tochka-developers/model-history
Latest Version:v0.6.0
PHP:8.1.*|8.2.*|8.3.*|8.4.*
Last Updated:Jul 31, 2026
Links: GitHub  ·  Packagist
Maintainer: tochka-developers

History for Laravel Models

Easily add keeping track of model modifications.

Installation

  1. Add "tochka-developers/model-history":"^0.1" to the require section of your composer.json

  2. Publish package assets:

php artisan vendor:publish 
  1. You may now edit the config file model-history.php to specify the name of the table to store history records. Please do it before running the migrations. Default name is history which is quite reasonable.

  2. Use \Tochka\ModelHistory\HasHistory trait in your model.

History structure

History records for all tracked models are stored in the same table specified in the config file (history is the default name). Each record contains the following data:

  • changed_at - time of modification;
  • entity_name - name of the table containing tracked model records;
  • entity_id - ID of the row in the tracked table the history entry relates to;
  • action - type of modification. The possible values are create, update, delete and restore.
  • new_data - a JSON containing new values. Therefore each history record is essentially a diff to the previous version of the model.

Warning

The history table always grows and is NEVER CLEANED UP by this package. Please consider the possibility of the history table becoming the largest in your database and occupying more space than all other tables ultimately exhausting all available disk space.

Related Packages

mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

21,010,090 1,982
kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6,282,182 647
mews/captcha

Laravel 5/6/7/8/9/10/11/12 Captcha Package

6,095,827 2,586
ajthinking/archetype

Programmatically edit PHP and Laravel files.

4,372,487 272