Looking to hire Laravel developers? Try LaraJobs

laravel-userstamps maintained by berthott

Description
Laravel Helper for Userstamps in Laravel
Author
Last update
2024/12/11 15:58 (dev-master)
License
Links
Downloads
945

Comments
comments powered by Disqus

test workflow

Laravel-Userstamps

A helper to maintain Userstamps in Laravel. Easily add and maintain userstamps by adding a trait to your model.

Installation

$ composer require berthott/laravel-userstamps

Usage

  • Create your table and corresponding model, eg. with php artisan make:model YourModel -m
  • Add $table->userstamps() to your migration
    • If you use the SoftDeletes trait on your model additionally add $table->softDeletesUserstamp()
  • Add the HasUserstamps trait to your newly generated model.
  • For some more macros see \berthott\Userstamps\UserstampsServiceProvider::register()
  • creator(), editor(), and destroyer() will be available for your convenience.

Options

You may change the column names by adding these constants to your model.

const CREATED_BY = 'alt_created_by';
const UPDATED_BY = 'alt_updated_by';
const DELETED_BY = 'alt_deleted_by';

Note that in this case you cannot use $table->userstamps() but need to define the columns separately with

$table->unsignedBigInteger('alt_created_by')->nullable();
$table->unsignedBigInteger('alt_updated_by')->nullable();
$table->unsignedBigInteger('alt_deleted_by')->nullable();

Compatibility

Tested with Laravel 10.x.

Credits

Inspired by https://github.com/WildsideUK/Laravel-Userstamps and https://github.com/hrshadhin/laravel-userstamps.

License

See License File. Copyright © 2023 Jan Bladt.