PHP code example of rembon / laravel-auditor

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

    

rembon / laravel-auditor example snippets


'providers' => [
    /*
    * Laravel Framework Service Providers...
    */
    ...

    /*
    * Package Service Providers...
    */
    \Rembon\LaravelAuditor\LaravelAuditorServiceProvider::class,

    /*
    * Application Service Providers...
    */
    ...
],



...
use Illuminate\Mail\Events\MessageSent;
use Illuminate\Notifications\Events\NotificationSent;
use Rembon\LaravelAuditor\Listeners\AuthorizeMail;
use Rembon\LaravelAuditor\Listeners\AuthorizeNotification;

protected $listen = [
    ...
    MessageSent::class => [
        AuthorizeMail::class,
    ],
    NotificationSent::class => [
        AuthorizeNotification::class,
    ],
];

Schema::create('audits', function (Blueprint $table) {
    $table->id();
    $table->foreignId('user_id')->nullable(); // modify this line into foreignUuid method, do not change the column name
    $table->string('url');
    $table->dateTime('datetime');
    $table->double('request_time');
    $table->string('route')->nullable();
    $table->json('abilities')->nullable();
    $table->json('emails')->nullable();
    $table->json('models')->nullable();
    $table->json('notifications')->nullable();
    $table->json('properties')->nullable();
    $table->timestamps();
});



use Rembon\LaravelAuditor\Traits\Auditable;

class User extends Authenticatable
{
    use ..., Auditable;
    
    ...
}

sh
php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=migrations
php artisan vendor:publish --tag=public
php artisan vendor:publish --tag=views
sh
php artisan migrate
sh
php artisan migrate --path=database/migrations/2050_06_14_042948_create_audits_table.php
sh
php artisan migrate --path=database/migrations/2050_07_13_093233_create_performances_table.php
sh
composer dump-autoload