定制 crescent-purchasing/filament-auditing 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

crescent-purchasing/filament-auditing

最新稳定版本:v1.1.0

Composer 安装命令:

composer require crescent-purchasing/filament-auditing

包简介

Basic Management of O3 IT's Laravel Auditing library

README 文档

README

Filament Auditing Banner

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

View and manage Audit History for your Laravel Models in Filament. Built upon the Laravel Auditing package by OwenIT.

Screenshots

Audit Overview

Audits table displaying multiple recorded Audits

Viewing Audits

Modal view of Audit information after clicking on an Audit

Filtering Audits

Modal view of form when filtering Audit History

Restoring Audits

Modal view of form when restoring to a past Audit

Features

Audit Resource

  • View all Audits for all Resources within Filament
  • Filter using a Query Builder
  • View the audited record as well as the user who triggered the audit
  • Uses cursor pagination by default for a performance boost

Relation Managers

  • View the audits of a specific record to see when it was changed
  • View the audits of a user to see what records they have changed see Owned Audits

Restoration

  • Restore audits to previous points in their history
  • Simple configuration for managing permission to perform a restoration

Installation

Prerequisites

This package requires the latest major version of Laravel Auditing, v14.

It'll be installed automatically, but it's recommended to install Laravel Auditing in your own repository.

Make sure to follow the installation instructions. It's recommended to give the full documentation a read, too.

composer require owen-it/laravel-auditing

Namely, make sure you publish the migration and configuration:

php artisan vendor:publish --provider "OwenIt\Auditing\AuditingServiceProvider" --tag="config"
php artisan vendor:publish --provider "OwenIt\Auditing\AuditingServiceProvider" --tag="migrations"
php artisan migrate

Install

You can then install this package via composer:

composer require crescent-purchasing/filament-auditing

Usage

To use this plugin within your panel, add it to your plugins() section in your PanelProvider:

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;
use Filament\Panel;
use Filament\PanelProvider;

class AuditPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('admin')
            // ...
            ->plugins([
                FilamentAuditingPlugin::make(),
            ]);
    }
}

This will automatically add the Resource Page to your Filament Panel. It should also provide some basic configuration that will work for most use-cases.

Relation Manager

The plugin allows you to view the audit history of a specific record. To do so, simply add the Relation Manager to the resource:

use CrescentPurchasing\FilamentAuditing\Filament\RelationManagers\AuditsRelationManager;

public static function getRelations(): array
{
    return [
        AuditsRelationManager::class,
    ];
}

Owned Audits

The plugin comes with the OwnedAuditsRelationManager. This by default doesn't have support with Laravel Auditing. However, it's easy to add the support. Simply add a relation function like the following to each of your User Models:

use Illuminate\Database\Eloquent\Relations\MorphMany;
use OwenIt\Auditing\Models\Audit;

/**
 * @return MorphMany<Audit, $this>
 */
public function ownedAudits(): MorphMany
{
    return $this->morphMany(Audit::class, 'user');
}

Then, add the relation manager to your Resources as normal:

use CrescentPurchasing\FilamentAuditing\Filament\RelationManagers\OwnedAuditsRelationManager;

public static function getRelations(): array
{
    return [
        OwnedAuditsRelationManager::class,
    ];
}

Configuration

You can configure a few parts of the application.

Cursor Pagination

Cursor Pagination for Audits is enabled by default. You can disable this using cursorPagination():

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->cursorPagination(false)

Audit Model

By default, the configured audit.implementation config value is used for the Audit Model. This can be modified using model()

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->model(\OwenIt\Auditing\Models\Audit::class)

Formatting Auditable Type

The Auditable Type in tables is formatted as a Headline of the Class Basename. You can customise this using a closure within formatAuditableTypeUsing():

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->formatAuditableTypeUsing(fn(string $value): string => strtoupper($value))

Formatting Event Name

The event names are turned into a Headline. You can customise this using formatEventUsing():

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->formatEventUsing(fn(string $value): string => strtoupper($value))

Navigation Group

No Navigation Group for the Resource is set by default. You can set this using navigationGroup():

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->navigationGroup('Administration')

Navigation Icon

The Resource icon by default is heroicon-o-clock. You can set this using navigationIcon():

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->navigationIcon('heroicon-o-check')

Restore Permission

The permission used for Audit restoration is restoreAudit by default. You can set this using restorePermission()

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->restorePermission('goToOldAudit')

Users

The default list of User classes is determined using the audit.user.guards config value. This then checks the list of auth providers in auth.providers. You can change this behaviour with users():

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;

FilamentAuditingPlugin::make()
    ->users([\CrescentPurchasing\FilamentAuditing\Tests\Models\User::class])

User Table Schema

By default, viewing user information of an Audit only displays 2 columns: email and id. You can specify additional columns with userSchema:

use CrescentPurchasing\FilamentAuditing\FilamentAuditingPlugin;
use Filament\Forms\Components\TextInput;

FilamentAuditingPlugin::make()
    ->userSchema([
        TextInput::make('first_name'),
        TextInput::make('last_name'),
    ])

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

crescent-purchasing/filament-auditing 适用场景与选型建议

crescent-purchasing/filament-auditing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.46k 次下载、GitHub Stars 达 10, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「crescent-purchasing」 「filament-auditing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 crescent-purchasing/filament-auditing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 crescent-purchasing/filament-auditing 我们能提供哪些服务?
定制开发 / 二次开发

基于 crescent-purchasing/filament-auditing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知