Package Data | |
---|---|
Maintainer Username: | Rukhsar |
Maintainer Contact: | rukhsar.man@gmail.com (Rukhsar Manzoor) |
Package Create Date: | 2016-11-25 |
Package Last Update: | 2016-11-25 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 03:02:59 |
Package Statistics | |
---|---|
Total Downloads: | 10 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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.
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.
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;
}
For example for abouve model you can get the history by using
$post->history;