rukhsar/modelhistory

Provides tracking of Laravel Models for creating, updating and deleting events
11
Install
composer require rukhsar/modelhistory
Latest Version:v1.0
PHP:>=5.4.0
License:MIT
Last Updated:Nov 25, 2016
Links: GitHub  ·  Packagist
Maintainer: Rukhsar

Laravel Eloquent Model History

Provides tracking of Laravel Models for creating, updating and deleting events. When a model which use ModelHistory trait call created/updated/deleted, an entry is written to the database with which user updated the model and some information about model changes.

Installation

Run the follwoing command

composer require rukhsar/modelhistory

Next, add the service provider in your array in config/app.php :


'providers' => [
    ...
            Rukhsar\ModelHistoryServiceProvider::class,
    ...
],

Publish the database migration

php artisan vendor:publish --provider="Rukhsar\ModelHistoryServiceProvider"

and run

php artisan migration

This will setup a model_history table in your database.

Use it

In you model, just add

use Rukhsar\Traits\ModelHistory;

and within you class defination use it like below

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Rukhsar\Traits\ModelHistory;

class Post extends Model
{
    use ModelHistory;


}

Get the history of a particular model

For example for abouve model you can get the history by using

$post->history;

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

634,760,849 9,707
laravel/framework

The Laravel Framework.

584,532,650 34,931
laravel/tinker

Powerful REPL for the Laravel framework.

493,838,477 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

408,553,772 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

387,976,821 4,658