PHP code example of hexadog / laravel-auditable

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

    

hexadog / laravel-auditable example snippets


use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::table('posts', function (Blueprint $table) {
    $table->auditable();
});

Schema::table('posts', function (Blueprint $table) {
    $table->dropAuditable();
});

use Hexadog\Auditable\Models\Traits\Auditable;

class Post extends Models
{
    use Auditable;

    // ...
}

// Get user responsible of the creation of the post
$post->createdBy;

// Get the creation date
$post->created_at;

// Get user responsible of the last update of the post
$post->updatedBy;

// Get the last update date
$post->updated_at;

// Get user responsible of the post deletion (ONLY if soft deletes are used)
$post->deletedBy;

// Get the soft deletion date
$post->deleted_at;