https://github.com/sansanlabs/laravel-userstamps
Package to add userstamps to models
https://github.com/sansanlabs/laravel-userstamps
creator destroyer editor laravel userstamps
Last synced: about 1 month ago
JSON representation
Package to add userstamps to models
- Host: GitHub
- URL: https://github.com/sansanlabs/laravel-userstamps
- Owner: sansanlabs
- License: mit
- Created: 2025-04-21T03:54:02.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-04-21T05:23:27.000Z (about 2 months ago)
- Last Synced: 2025-04-21T05:47:00.031Z (about 2 months ago)
- Topics: creator, destroyer, editor, laravel, userstamps
- Language: PHP
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Userstamps
[](https://packagist.org/packages/sansanlabs/laravel-userstamps)
[](https://github.com/sansanlabs/laravel-userstamps/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/sansanlabs/laravel-userstamps/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/sansanlabs/laravel-userstamps)## Installation
You can install the package via composer:
```bash
composer require sansanlabs/laravel-userstamps
```You can publish the config file with:
```bash
php artisan vendor:publish --tag="userstamps-config"
```This is the contents of the published config file:
```php
return [
/*
* Specify the column type used in the schema for the account ID
*
* Options: increments, bigIncrements, uuid, ulid
* Default: bigIncrements
*/
"users_table_id_column_type" => "bigIncrements",/*
* Specify the column name used as the foreign key reference for the account ID. Make sure all user tables have an ID column name that matches the one you define below.
*/
"users_table_id_column_name" => "id",/*
* Specify the column that stores the ID of the user who initially created the entry
*/
"created_by_column" => "created_by",/*
* Specify the column that holds the ID of the user who last updated the entry
*/
"updated_by_column" => "updated_by",/*
* Specify the column that contains the ID of the user who removed the entry
*/
"deleted_by_column" => "deleted_by",/*
* Indicate whether to include soft-deleted records in queries
*/
"with_trashed" => false,
];
```## Usage
Add the macro to your migration of your model
```php
public function up(){
Schema::create('table_name', function (Blueprint $table) {
...
$table->userstamps();
$table->softUserstamps();
});
}
```Add the macro to your existing table
```php
public function up()
{
Schema::table('table_name', function($table) {
...
$table->userstamps();
$table->softUserstamps();
});
}public function down()
{
Schema::table('table_name', function($table) {
$table->dropUserstamps();
$table->dropSoftUserstamps();
});
}
```Add the Trait to your model
```php
use SanSanLabs\UserStamps\Concerns\HasUserstamps;class Example extends Model {
use HasUserstamps;
}
```There will be methods available to retrieve the user object which performs the action for creating, updating or deleting
```php
$model->creator; // the user who created the model
$model->editor; // the user who last updated the model
$model->destroyer; // the user who deleted the model
```## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Edi Kurniawan](https://github.com/edikurniawan-dev)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.