turahe / laravel-userstamps
Adds user tracking fields to Laravel models.
v1.1.1
2025-07-19 18:14 UTC
Requires
- php: ^8.2
- laravel/framework: ^10.0 || ^11.0 || ^12.0
Requires (Dev)
- laravel/pint: ^1.17
- orchestra/testbench: ^9.0 || ^10.0
- dev-master
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- dev-dependabot/github_actions/codecov/codecov-action-5
- dev-dependabot/composer/doctrine/dbal-tw-4.3
- dev-dependabot/github_actions/actions/cache-4
- dev-dependabot/github_actions/github/codeql-action-3
- dev-dependabot/github_actions/dependabot/fetch-metadata-2
- dev-dependabot/github_actions/actions/upload-artifact-4
This package is auto-updated.
Last update: 2025-07-19 18:16:47 UTC
README
A Laravel package to automatically add created_by
, updated_by
, and deleted_by
fields to your Eloquent models, supporting multi-database testing and modern CI/CD.
Features
- Automatically tracks which user created, updated, or deleted a model
- Works with Laravel 10, 11, and 12
- Supports MySQL, PostgreSQL, and SQLite
- Easy integration with Eloquent models
- Database schema macros for userstamps
- Thoroughly tested with GitHub Actions matrix and Docker
- Code style and security checks included
Installation
composer require turahe/laravel-userstamps
Usage
1. Add the Trait
use Turahe\UserStamps\Concerns\HasUserStamps; class Post extends Model { use HasUserStamps; }
2. Migrate Your Table
Add the userstamps columns using the provided schema macros:
Schema::create('posts', function (Blueprint $table) { $table->id(); $table->string('title'); $table->userstamps(); // Adds created_by and updated_by $table->softUserstamps(); // Adds deleted_by $table->timestamps(); $table->softDeletes(); });
Configuration
You can publish and customize the config:
php artisan vendor:publish --provider="Turahe\UserStamps\UserStampsServiceProvider" --tag="config"
Testing
Local Testing
Requirements: Docker, PHP 8.2+, Composer
# Start database containers docker-compose up -d # Run all tests (SQLite, MySQL, PostgreSQL) composer test:all # Or test with a specific database composer test:mysql composer test:postgres composer test # SQLite (default)
GitHub Actions
- Matrix tests for Laravel 10/11/12, PHP 8.2/8.3/8.4, and all supported databases
- Code style checked with Laravel Pint
- Security scanning with Composer Audit and CodeQL
Docker Setup
See DOCKER_README.md for full details.
- MySQL:
127.0.0.1:3306
, user:laravel_userstamps
, pass:password
- PostgreSQL:
127.0.0.1:5432
, user:laravel_userstamps
, pass:password
Security
- Composer audit and CodeQL scanning in CI
- Dependabot for automated dependency updates
Contributing
- Fork the repo
- Create your feature branch (
git checkout -b feature/foo
) - Commit your changes
- Push to the branch (
git push origin feature/foo
) - Open a pull request
License
MIT © Nur Wachid