Pros:
created_by, updated_by, and deleted_by for models. This is critical for compliance, debugging, and user accountability._type columns), enabling flexibility for multi-tenant or multi-user-type systems (e.g., admins vs. regular users).with_trashed config), preserving audit trails even for trashed records.created_by_column, updated_by_column) and ID types (e.g., bigIncrements, uuid), reducing schema conflicts.userstamps(), softUserstamps()), promoting consistency across migrations.Cons:
whereCreatedBy($user)). This may require custom logic or additional packages.creating, updating) for pre/post-processing of userstamps.HasUserstamps trait bundles all functionality, which could lead to over-fetching or unused methods in some models.Model::where(...)->update() may not auto-set updated_by).illuminate/contracts). Verify compatibility with your stack (e.g., Laravel 10.x may need adjustments).created_by_id, created_by_type [if polymorphic], updated_by_id, updated_by_type, deleted_by_id, deleted_by_type).dropUserstamps()). Test in staging first.User model exists (configurable via users_model). Works with Laravel’s built-in auth or custom auth systems.auth()->user() resolver is compatible.| Risk Area | Severity | Mitigation |
|---|---|---|
| Schema Conflicts | High | Validate column names (created_by_column) don’t clash with existing fields. |
| Polymorphic Overhead | Medium | Disable is_using_morph if not needed to reduce storage and query complexity. |
| Performance | Low | Userstamps add minimal overhead (~1–2 extra joins per query). Benchmark in prod. |
| Backward Compatibility | Medium | Test with existing migrations and rollback procedures. |
| Custom Auth Systems | Medium | Ensure auth()->user() returns an instance of users_model. |
| Soft Deletes Interaction | Low | Confirm with_trashed behavior aligns with your soft-delete strategy. |
created_by/updated_by? If so, consider adding custom query builders.leftJoin('users')) for userstamp data?Model::update()) may not auto-populate updated_by.users table reference?dropUserstamps)?auth()->user())?updated_by = API client ID).auth()->setUser($user)).users_model.users_model.$table->userstamps()).use HasUserstamps).createdBy matches the expected user).dropUserstamps()).userstamps() and run it in a maintenance window.created_by/updated_by for existing records (if needed) via a data job.php artisan vendor:publish --tag="userstamps-config").created_by_id/updated_by_id if querying by user is common.getCreatedByName()).| Component | Compatibility | Notes |
|---|---|---|
| Laravel Versions | 11.x, 12.x, 13.x | Laravel 10.x may require adjustments. |
| PHP Versions | 8.3+ | Aligns with Laravel’s latest requirements. |
| Database | MySQL, PostgreSQL, SQLite, SQL Server (via Eloquent) | Test with your DBMS for schema generation. |
| Auth Systems | Laravel Breeze, Sanctum, Passport, Custom | Ensure auth()->user() returns users_model. |
| Soft Deletes | Laravel’s SoftDeletes trait |
Works with with_trashed config. |
| Polymorphic Relations | Eloquent polymorphic relations | Only enable if multi-user-type systems are needed. |
| Testing Frameworks | Pest, PHPUnit | Dev dependencies include Testbench for Laravel testing. |
users_model is properly configured (e.g., App\Models\User).php artisan vendor:publish --tag="userstamps-config").is_using_morph, users_table, and column names.userstamps() to new model migrations.use HasUserstamps; to target models.createdBy, updatedBy, and deletedBy accessors.How can I help you explore Laravel packages today?