reallyli / laravel-activitylog
一个非常简单的活动日志记录器,用于监控您网站或应用程序的用户
Requires
- php: ^7.2
- illuminate/config: 5.7.*|5.8.*|^6.0
- illuminate/database: 5.7.*|5.8.*|^6.0
- illuminate/support: 5.7.*|5.8.*|^6.0
- spatie/string: ^2.1
Requires (Dev)
- ext-json: *
- orchestra/testbench: 3.8.*|^4.0
- phpunit/phpunit: ^7.5|^8.0
- scrutinizer/ocular: ^1.5
- dev-master
- 3.9.3
- 3.9.2
- 3.9.1
- 3.9.0
- 3.8.0
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.3
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.0
- v2.x-dev
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.0
- 2.5.1
- 2.5.0
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- v1.x-dev
- v1.16.0
- 1.15.5
- 1.15.4
- 1.15.3
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.1
- dev-issue-623
- dev-analysis-XWB3e5
- dev-issue-520
- dev-fix-nullable-dates
- dev-issue-528
This package is auto-updated.
Last update: 2024-09-20 18:23:46 UTC
README
spatie/laravel-activitylog
包提供易于使用的功能来记录您应用程序用户的活动。它还可以自动记录模型事件。该包将所有活动存储在 activity_log
表中。
以下是如何使用它的演示
activity()->log('Look, I logged something');
您可以使用 Spatie\Activitylog\Models\Activity
模型检索所有活动。
Activity::all();
以下是一个更高级的示例
activity() ->performedOn($anEloquentModel) ->causedBy($user) ->withProperties(['customProperty' => 'customValue']) ->log('Look, I logged something'); $lastLoggedActivity = Activity::all()->last(); $lastLoggedActivity->subject; //returns an instance of an eloquent model $lastLoggedActivity->causer; //returns an instance of your user model $lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue' $lastLoggedActivity->description; //returns 'Look, I logged something'
以下是一个关于 事件记录 的示例。
$newsItem->name = 'updated name'; $newsItem->save(); //updating the newsItem will cause the logging of an activity $activity = Activity::all()->last(); $activity->description; //returns 'updated' $activity->subject; //returns the instance of NewsItem that was saved
调用 $activity->changes()
将返回此数组
[ 'attributes' => [ 'name' => 'updated name', 'text' => 'Lorum', ], 'old' => [ 'name' => 'original name', 'text' => 'Lorum', ], ];
文档
您可以在 https://docs.spatie.be/laravel-activitylog 上找到文档。
在使用包时遇到困难?发现了一个错误?您是否有关于改进活动日志的一般问题或建议?请随意在 GitHub 上 创建一个问题,我们会尽快处理。
如果您发现了一个安全问题,请通过邮件 freek@spatie.be 联系我们,而不是使用问题跟踪器。
安装
您可以通过 composer 安装此包
composer require spatie/laravel-activitylog
包将自动注册自己。
您可以使用以下命令发布迁移
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="migrations"
注意:默认迁移假设您正在使用整数作为模型 ID。如果您正在使用 UUID 或其他格式,请在继续之前调整已发布迁移中 subject_id 和 causer_id 字段的格式。
发布迁移后,您可以通过运行迁移来创建 activity_log
表
php artisan migrate
您可以选择以下方式发布配置文件
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"
这是已发布配置文件的内容
return [ /* * If set to false, no activities will be saved to the database. */ 'enabled' => env('ACTIVITY_LOGGER_ENABLED', true), /* * When the clean-command is executed, all recording activities older than * the number of days specified here will be deleted. */ 'delete_records_older_than_days' => 365, /* * If no log name is passed to the activity() helper * we use this default log name. */ 'default_log_name' => 'default', /* * You can specify an auth driver here that gets user models. * If this is null we'll use the default Laravel auth driver. */ 'default_auth_driver' => null, /* * If set to true, the subject returns soft deleted models. */ 'subject_returns_soft_deleted_models' => false, /* * This model will be used to log activity. * It should be implements the Spatie\Activitylog\Contracts\Activity interface * and extend Illuminate\Database\Eloquent\Model. */ 'activity_model' => \Spatie\Activitylog\Models\Activity::class, /* * This is the name of the table that will be created by the migration and * used by the Activity model shipped with this package. */ 'table_name' => 'activity_log', /* * This is the database connection that will be used by the migration and * the Activity model shipped with this package. In case it's not set * Laravel database.default will be used instead. */ 'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), ];
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
升级
有关详细信息,请参阅 UPGRADING。
测试
composer test
贡献
有关详细信息,请参阅 CONTRIBUTING。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 freek@spatie.be 联系我们,而不是使用问题跟踪器。
明信片软件
您可以自由使用此包,但如果它进入您的生产环境,我们非常感谢您从您的家乡给我们寄一张明信片,说明您正在使用我们哪个包。
我们的地址是:Spatie,Samberstraat 69D,2060 Antwerp,比利时。
我们将发布收到的所有明信片 在我们的公司网站上。
致谢
支持我们
Spatie 是一家位于比利时的安特卫普网络设计公司。您可以在我们的网站上找到所有我们的开源项目的概述 在这里。
您的业务是否依赖于我们的贡献?请通过Patreon联系我们并支持我们。所有承诺都将专门用于分配人员维护和开发新酷炫功能。
许可证
MIT许可证(MIT)。更多详细信息,请参阅许可证文件。