PHP code example of danielemontecchi / laravel-userstamps

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

    

danielemontecchi / laravel-userstamps example snippets


use DanieleMontecchi\LaravelUserstamps\Traits\HasUserstamps;

class Post extends Model
{
    use HasUserstamps;
}

$table->userstamps();

$table->softDeletesBy();

Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');

    $table->userstamps();       // created_by, updated_by
    $table->timestamps();       // created_at, updated_at
    $table->softDeletes();      // deleted_at
    $table->softDeletesBy();    // deleted_by
});

$post->creator;    // The user who created the model
$post->updater;    // The user who last updated the model
$post->destroyer;  // The user who deleted the model

Post::disableUserstamps();

Post::create(['title' => 'Imported without tracking']);

Post::enableUserstamps();