created_by, updated_by, and deleted_by fields. Reduces manual boilerplate in models.SoftDeletes trait with deleted_by tracking, enhancing compliance and debugging.created_by/updated_by (e.g., whereCreatedBy()), requiring manual implementation.UserStampCreated) for post-processing (e.g., logging, notifications).users table with an id column (or UUID equivalent) for foreign key references.created_by/updated_by values are set correctly in various scenarios (e.g., API calls, CLI commands, scheduled jobs).null or a system user).created_by/updated_by values requires careful handling to avoid data loss or corruption.DB::statement() or raw SQL to populate historical data, then enable the trait for new records.created_by user details) or use Laravel’s query caching.updated_by).version column) can mitigate this.Authentication Layer:
User Model:
users table structure compatible (e.g., id column type matches created_by/updated_by)?Admin, Guest) that need special handling?Existing Data:
Query Patterns:
created_by/updated_by? If so, custom accessors or scopes may be needed.Model::whereCreatedBy($userId)->get();Soft Deletes:
SoftDeletes widely used in the codebase? If not, the deleted_by feature may add unnecessary complexity.Testing Strategy:
created_by, updated_by (and deleted_by if using SoftDeletes) to existing tables.Schema::table('table_name', function (Blueprint $table) {
$table->userstamps();
$table->userstampSoftDeletes();
});
$table->userstampsUuid();
HasUserstamps trait to Eloquent models:
use Wildside\Userstamps\HasUserstamps;
class Post extends Model {
use HasUserstamps;
}
use Wildside\Userstamps\HasUserstamps;
use Illuminate\Database\Eloquent\SoftDeletes;
class Post extends Model {
use HasUserstamps, SoftDeletes;
}
created_by/updated_by for existing records:
DB::table('posts')->update([
'created_by' => DB::raw('(SELECT id FROM users WHERE id = 1)'), // Example: Default to admin
]);
creating, updating) may need updates to handle the new fields.Observables, Timestamps). The package should work alongside them.laravel-medialibrary, spatie/activitylog).Post, Setting) to test the trait and migration process.User, Order).created_by/updated_by columns if frequently queried.created_by/updated_by in model events or controllers.created_by/updated_by are not null when they shouldn’t be (e.g., API calls without auth).created_by/updated_by.created_by/updated_by columns will improve query performance for filtering:
Schema::table('posts', function (Blueprint $table) {
$table
How can I help you explore Laravel packages today?