Best laravel framework open-source packages.

Laravel previousable

Generate previous attributes when saving Eloquent models. From https://twitter.com/SteveTheBauman/status/1524865758043553816. Credit to Steve Bauman.
Updated 7 months ago

Generate previous attributes when saving Eloquent models

Laravel Previousable

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a trait that will generate previous attributes when saving any Eloquent model.

$model = EloquentModel::create(['name' => 'Awesome application']);
$model->update(['name' => 'New attribute']);

$model->getPrevious(); // ['name' => 'Awesome application']
$model->getPrevious('name'); // 'Awesome application'

Support us

We invest a lot of resources into creating best in class open source packages. You can support by donating to

I appreciate you if you connect with me on Twitter

Installation

You can install the package via composer:

composer require sawirricardo/laravel-previousable

Usage

Simply use the Sawirricardo\Previousable\HasPrevious trait in your Eloquent Model.

Here's an example of how to implement the trait:

namespace App\Models;

use Sawirricardo\Previousable\HasPrevious;
use Illuminate\Database\Eloquent\Model;

class EloquentModel extends Model
{
    use HasPrevious;
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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