Laravel Userstamps is a simple Laravel package for your Eloquent Model user specific feilds. This package automatically inserts/updates an user id on your table on who created, last updated and deleted the record.
- Add repositories in composer.json
"repositories": [
{
"url": "https://github.com/hrshadhin/laravel-userstamps.git",
"type": "git"
}
],
- Add the package name in require with the branch name after the dev:
"hrshadhin/laravel-userstamps": "dev-master"
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->increments('id');
$table->string('name', 100);
$table->userstamps();
$table->timestamps();
});
Then use UserstampsTrait
on your model.
namespace App;
use Charghat\Userstamps\UserstampsTrait;
class User extends Model
{
use UserstampsTrait;
}
You can drop auditable columns using dropUserstamps()
method.
Schema::create('users', function (Blueprint $table) {
$table->dropUserstamps();
});
And your done!
The MIT License (MIT). Please see License File for more information.