bolechen/nova-activitylog
Composer 安装命令:
composer require bolechen/nova-activitylog
包简介
A tool to activity logger to monitor the users of your Laravel Nova.
README 文档
README
A tool to activity logger to monitor the users of your Laravel Nova.
- Behind the scenes spatie/laravel-activitylog is used.
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require bolechen/nova-activitylog
You can publish the migration with:
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
Note: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject_id and causer_id fields in the published migration before continuing.
After publishing the migration you can create the activity_log table by running the migrations:
php artisan migrate
You can optionally publish the config file with:
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"
You may only want to log actions from nova, put this line to your .env files let default logger off.
ACTIVITY_LOGGER_ENABLED=false
How to use
Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.
// in app/Providers/NovaServiceProvder.php // ... public function tools() { return [ // ... new \Bolechen\NovaActivitylog\NovaActivitylog(), ]; }
Because the backend uses the spatie/laravel-activitylog package, you need to let your model use the Spatie\Activitylog\Traits\LogsActivity trait.
Here's an example:
use Illuminate\Database\Eloquent\Model; use Spatie\Activitylog\Traits\LogsActivity; class NewsItem extends Model { use LogsActivity; protected $fillable = ['name', 'text']; protected static $logAttributes = ['name', 'text']; }
For more advanced usage can look at the doc: https://docs.spatie.be/laravel-activitylog/v3/advanced-usage/logging-model-events
Authorizing
Typical usage of tool authorizing using ->canSee() or ->canSeeWhen() when registering the tool will NOT work. To authorize the tool, simply make and register a Laravel policy for the ActivityLog model. If a user is not able to view them according to the policy, the tool will not show.
Customize
If you want to customize the tools. Eg: add filters or cards, you can create your owner resource file extends the original like this:
use Bolechen\NovaActivitylog\Resources\Activitylog; class Activity extends Activitylog { public function filters(Request $request) { return [ // Your customize filters, etc... new Filters\LogsType(), ]; } }
Next up, publish the config file with:
php artisan vendor:publish --provider="Bolechen\\NovaActivitylog\\ToolServiceProvider" --tag="config"
And change the resource in config/nova-activitylog.php to your custom nova resource.
License
The MIT License (MIT). Please see License File for more information.
bolechen/nova-activitylog 适用场景与选型建议
bolechen/nova-activitylog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 734.48k 次下载、GitHub Stars 达 99, 最近一次更新时间为 2019 年 03 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「log」 「nova」 「laravel」 「activity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bolechen/nova-activitylog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bolechen/nova-activitylog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bolechen/nova-activitylog 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Laravel 5.x.x library for integration Monolog Sentry
统计信息
- 总下载量: 734.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 99
- 点击次数: 32
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-07
