v2.2.0 2023-03-09 15:30 UTC

This package is auto-updated.

Last update: 2023-05-09 16:01:10 UTC


Latest Version on Packagist Total Downloads

Archivalist is a minimal package designed to make archiving changes to Laravel models easy.


You can install the package via composer:

composer require pderas/archivalist


Simply add the Pderas\Archivalist\Traits\HasArchives to any model you wish to archive.

use Pderas\Archivalist\Traits\HasArchives;
class Post extends Model {
    use HasArchives;

If you wish certain columns to always be archived, this can be accomplished by adding wither a archived property or method to the model

use Pderas\Archivalist\Traits\HasArchives;
class Post extends Model {
    use HasArchives;

    protected $archived = [

    // Alternatively...
    protected function archived() {
        return [
            'updated_at' => $this->getOriginal('updated_at'),
            'is_archived' => true

Archives can be 'rehydrated' into the state of the original model

$user->company = 'Pderas';

$archive = $user->archives()->first(); // => \Pderas\Archivalist\Models\Archive
$original = $archive->rehydrate(); // => \App\User

A Collection with the full history of the model can be acquired using ->getHistory()

$user->getHistory(); // A user model for every state the user was in

Mass assignment is not supported, in which case you must use the following workaround:

//  Do not do
    ->update(['status','closed']); // This will fail

//  Do this instead

Support for beforeArchive has been added. Implement the method beforeArchive on any model which uses HasArchives trait to run any extra logic before the primary archives logic is ran.

// SomeModel which uses HasArchives

public function beforeArchive() {
    //  Put logic here to be ran before the primary archives logic is ran
    //  useful for automating tasks such as always writing user->id, etc


composer test


Please see CHANGELOG for more information what has changed recently.


If you discover any security related issues, please email reed.jones@pderas.com instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.