fnematov/laravel-userstamps

A simple Laravel package for Eloquent Model user specific fields.

v1.5 2021-03-02 00:00 UTC

This package is auto-updated.

Last update: 2024-05-20 23:08:56 UTC


README

Laravel Userstamps is a simple Laravel package for your Eloquent Model user specific fields. This package automatically inserts/updates an user id on your table on who created, last updated and deleted the record.

Install

  1. Add repositories in composer.json
composer require fnematov/laravel-userstamps

Usage

Update your model's migration and add created_by, updated_by and deleted_by field using the userstamps() blueprint macro.

Schema::create('users', function (Blueprint $table) {
    $table->userstamps();
});

Then use UserstampsTrait on your model.

namespace App;

use Fnematov\Userstamps\UserstampsTrait;

class User extends Model
{
    use UserstampsTrait;
}

Dropping columns

You can drop auditable columns using dropUserstamps() method.

Schema::create('users', function (Blueprint $table) {
    $table->dropUserstamps();
});

And your done!

License

The MIT License (MIT). Please see License File for more information.