PHP code example of oneseven9955 / laravel-auditing-filesystem

1. Go to this page and download the library: Download oneseven9955/laravel-auditing-filesystem 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/ */

    

oneseven9955 / laravel-auditing-filesystem example snippets


    // ...
    'drivers' => [
        'database' => [
            'table'      => 'audits',
            'connection' => null,
        ],
        'filesystem' => [
            'disk'      => 'local',     // The registered name of any filesystem disk in the application
            'dir'       => 'audit',     // The directory on the disk where the audit csv files will be saved
            'filename'  => 'audit.csv', // The filename of the audit file
            'rotation'  => 'single',    // One of 'single', 'daily', or 'hourly'
        ],
    ],
    // ...


namespace App\Models;

use OneSeven9955\Auditing\Drivers\FilesystemDriver;
use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Contracts\Auditable;

class Article extends Model implements Auditable
{
    use \OwenIt\Auditing\Auditable;

    /**
     * Filesystem Audit Driver.
     *
     * @var \OneSeven9955\Auditing\Drivers\FilesystemDriver
     */
    protected $auditDriver = FilesystemDriver::class;

    // ...
}

use OneSeven9955\Auditing\Drivers\FilesystemDriver;

app(FilesystemDriver::class)->bufferStart();
    // ...
    // PERFORM MODEL CHANGES
    // ...
app(FilesystemDriver::class)->bufferFlush(); // flush all audit records into a file at once