PHP code example of mohamedhekal / audittrail

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

    

mohamedhekal / audittrail example snippets


use Hekal\AuditTrail\Concerns\Auditable;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    use Auditable;
}

use Hekal\AuditTrail\Facades\AuditTrail;

AuditTrail::startBatch();
AuditTrail::record('invoice.voided', $invoice, oldValues: ['status' => 'open'], newValues: ['status' => 'void']);
AuditTrail::endBatch();

use Hekal\AuditTrail\Models\AuditRecord;

AuditRecord::query()
    ->forSubject($order)
    ->forEvent('updated')
    ->latest()
    ->get();

Route::middleware(['api', 'audittrail.api'])->group(...);
bash
composer vendor:publish --tag=audittrail-config
php artisan migrate
bash
php artisan audittrail:purge --days=365
php artisan audittrail:export storage/audit.jsonl --event=deleted