百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

nova-activitylog

> 后端框架
开源

一个用于监控 Laravel Nova 用户的活动日志记录器

100 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个用于监控 Laravel Nova 用户的活动日志记录器

Nova tool for activity log

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:

bash
composer require bolechen/nova-activitylog

You can publish the migration with:

bash
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:

bash
php artisan migrate

You can optionally publish the config file with:

bash
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.

env
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.

php
// 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:

php
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:

php
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:

bash
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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPlaravelnova

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架