duyngha / motrac
Tracking model activities using MongoDB in Laravel
0.2
2021-08-05 07:02 UTC
Requires
- jenssegers/mongodb: ^3.8
This package is auto-updated.
Last update: 2024-05-05 12:58:05 UTC
README
Installation
composer require duyngha/motrac
How to use
- Add this trait to the model that you want to tracking.
use Duyngha\ModelTracker\Traits\Trackable; class Task extends Model { use Trackable; }
- Create "trackable" model that extends
Duyngha\ModelTracker\Models\TrackerModel
model.
use Duyngha\ModelTracker\Models\TrackerModel; class TaskTrackable extends TrackerModel { protected $collection = 'task_revisions'; // This collection property determines name of collection will be created in MongoDB }
Then, assign it for $trackableModel
property in main model.
use Duyngha\ModelTracker\Traits\Trackable; class Task extends Model { use Trackable; protected $trackableModel = TaskTrackable::class; }
- If you would like to tracking the model on specific fields only. Then add the fields into
$trackingFields
array in main model.
class Task extends Model { protected $trackingFields = [ 'name' ]; }
Changelog
Please see CHANGELOG for more information on what has changed recently.