PHP code example of souravmsh / audit-trail

1. Go to this page and download the library: Download souravmsh/audit-trail 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/ */

    

souravmsh / audit-trail example snippets


use Souravmsh\AuditTrail\Facades\AuditTrail;
        
// Supports both array-based calls
AuditTrail::log([
    "type"       => "CREATED",
    "message"    => "A recond has created",
    "model_type" => "App\Models\User",
    "model_id"   => 1,
    "data"       => ["title" => ["old" => "John", "new" => "Alex"]],
]);

// Handles loggedin without a model
AuditTrail::log([
    "type"    => config('audit-trail.migration.type.loggedin'),
    "message" => "A user login in 1."
]);

// or
AuditTrail::log("LOGGEDIN", "A user logged in 2.");

use Souravmsh\AuditTrail\Facades\AuditTrail;

$auditLogs = AuditTrail::history([
    "per_page"     => "10",
    "limit"        => "100",
    "model_type"   => "App\Models\User",
    "model_id"     => "1",
    "creator_type" => "",
    "creator_id"   => "",
    "show_model"   => "false",
    "show_creator" => "true"
]);
bash
php artisan audit-trail:install