labrodev/laravel-trackable
Composer 安装命令:
composer require labrodev/laravel-trackable
包简介
Laravel package providing a reusable trait that automatically assigns a document number to Eloquent models upon creation.
README 文档
README
The ModelHasActorTracker trait provides automatic tracking of the user who creates or updates a model record by setting created_by and updated_by attributes. This trait is useful in applications that require auditing changes and maintaining a record of the users responsible for creating and updating model instances.
Installation
To install the package, run the following command in your Laravel project:
composer require labrodev/laravel-trackable
Requirements
- PHP 8.1 or higher
Configuration
After installing the package, no additional configuration is needed to start using the UUID trait in your models.
Usage
To use the ModelHasActorTracker trait, simply include it in your Eloquent model:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Labrodev\Trackable\ModelHasActorTracker; class ExampleModel extends Model { use ModelHasActorTracker; }
Ensure that your model has 'updated_by', 'created_by' columns in model database table.
If it is not, you may add it through Laravel migration:
$table->string('created_by'); $table->string('updated_by')
Override column names
If the columns in your database table designated for tracking user actions through model has a names different from the default, you can customize the trait to accommodate this.
Simply override the trait method in your model by adding the following methods with your specific column names:
/** * Column to track the actor for creation. * * @return string */ protected function modelHasActorTrackerCreatedByColumn(): string { return 'created_by'; // put your column name instead }
/** * Column to track the actor for updates * * @return string */ protected function modelHasActorTrackerUpdatedByColumn(): string { return 'updated_by'; // put your column name instead }
Overwrite logic of actor identifier
You may overwrite logic of actor identifier which making actions through model by override the trait method:
/** * @return mixed */ protected function modelHasActorTrackerIdentifier(): mixed { // Put your own logic }
Testing
To run the tests included with the package, execute the following command:
composer test
For static analysis to check the package code, execute the followin command:
composer analyse
Security
If you discover any security-related issues, please email admin@labrodev.com instead of using the issue tracker.
Credits
Labro Dev
License
The MIT License (MIT). Please see License File for more information.
labrodev/laravel-trackable 适用场景与选型建议
labrodev/laravel-trackable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「number」 「laravel」 「models」 「eloquent」 「laravel-package」 「labrodev」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 labrodev/laravel-trackable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 labrodev/laravel-trackable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 labrodev/laravel-trackable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Wordpress Query Builder class library for custom models and data querying.
A package for working with arbitrary precision numbers in Laravel.
A Laravel package for managing model drafts.
A package to better handle database operations via Eloquent Models.
Gambling Algorithms for Certification.
Validates Turkish National Identification Number
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-13