Download the PHP package phpcollective/tracker without Composer
On this page you can find all versions of the php package phpcollective/tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpcollective/tracker
More information about phpcollective/tracker
Files in phpcollective/tracker
Package tracker
Short Description Track your Elequent Model
License MIT
Informations about the package tracker
Laravel Model Tracker
By default, Eloquent automatically manage created_at and updated_at columns to exist on your tables. In addition to this it also manage a deleted_at attribute if the model use "soft delete". However it is very tedious job to manage who create/update the model as well as delete (if soft delete). This also a indication of code repetition.
If you wish to have these automatically managed by Eloquent, Tracker is a nice and convenient way to do this.
Install
You may use Composer to install the package into your Laravel project:
Laravel 5.5+:
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
Database: Migrations
To add created_by and updated_by columns in your table you want to track just use $table->track() method in your table migration file. For dropping the columns use $table->dropTrack().
If Your table contains soft delete columns, just pass boolean true in the method. It will add a deleted_by column in database.
Model
Add Trackable trait in model you want to track. Now it will handle all CRUD event by the authenticate user.
Usage
Trackable trait provides three belongsTo relationship with Authenticated Users. creator(), editor(), destroyer()
Credits
License
Laravel Model Tracker is open-sourced software licensed under the MIT license.