PHP code example of digitalcloud / laravel-blameable

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

    

digitalcloud / laravel-blameable example snippets



    'providers' => [
        DigitalCloud\Blameable\BlameableServiceProvider::class,
    ];




return [
    'column_names' => [
        'createdByAttribute' => 'created_by',
        'updatedByAttribute' => 'updated_by',
        'deletedByAttribute' => 'deleted_by',
    ],
     'models' => [
         'user' => \App\User::class
     ]
];




namespace App;

use DigitalCloud\Blameable\Traits\Blameable;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use Blameable;
}


      \App\Post::addBlameableColumns();
    

$post = \App\Post::find(1);
$creator = $post->creator;
$editor = $post->editor;
$deletor = $post->deletor;


    Schema::table($table, function (Blueprint $table) {
        // this will add created_by, updated_by and updated_by columns on your table.
        $table->blameable();
    });
            
bash

    php artisan vendor:publish --provider="DigitalCloud\Blameable\BlameableServiceProvider" --tag="config"

bash
      php artisan blameable:add-blameable-columns App\Post