PHP code example of rummykhan / moloquent-logger

1. Go to this page and download the library: Download rummykhan/moloquent-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rummykhan / moloquent-logger example snippets


RummyKhan\MoloquentLogger\MoloquentLoggerServiceProvider::class,,



namespace App;

use Jenssegers\Mongodb\Eloquent\Model;
use RummyKhan\MoloquentLogger\Logger\MoloquentLogger;

class Post extends Model{
    
    use MoloquentLogger;
    
}



$post = Post::find(1);

dd($post->logs);



$post = Post::find(1);

dd($post->stateAfter('2017-03-17'));



$post = Post::find(1);

dd($post->stateBefore('2017-03-17'));

bash
php artisan vendor:publish
bson
{
    "_id" : ObjectId("58bf371ddd73170408004836"),
    "request" : [],
    "before" : {
        "name" : "eod nhoj",
        "type" : "admin"
    },
    "after" : {
        "name" : "john doe",
        "type" : "user"
    },
    "before_model" : {
        "_id" : "58bf3388dd7317040800482e",
        "name" : "eod nhoj",
        "email" : "[email protected]",
        "updated_at" : "2017-03-07 22:41:20",
        "created_at" : "2017-03-07 22:26:16",
        "type" : "admin"
    },
    "after_model" : {
        "_id" : "58bf3388dd7317040800482e",
        "name" : "john doe",
        "email" : "[email protected]",
        "updated_at" : "2017-03-07 22:41:20",
        "created_at" : "2017-03-07 22:26:16",
        "type" : "user"
    },
    "scope" : {
        "file" : "/home/user/laravel/routes/web.php",
        "line" : 29,
        "function" : "save",
        "class" : "Illuminate\\Database\\Eloquent\\Model",
        "object" : {},
        "type" : "->",
        "args" : []
    },
    "user_id" : null,
    "action" : "update",
    "moloquent_type" : "App\\User",
    "moloquent_id" : "58bf3388dd7317040800482e",
    "updated_at" : ISODate("2017-03-07T22:41:33.359Z"),
    "created_at" : ISODate("2017-03-07T22:41:33.359Z")
}