andreshg112/laravel-auditing-notifications

此包已弃用,不再维护。未建议替代包。

owen-it/laravel-auditing 包的通知驱动。允许通过自定义通道发送包含审计数据的通知。

1.4.0 2023-09-25 02:18 UTC

This package is auto-updated.

Last update: 2024-09-25 04:25:17 UTC


README

Latest Version on Packagist Build Status StyleCI Scrutinizer Code Quality Code Coverage Total Downloads

此包允许您发送包含审计数据的通知,而不是将其保存到可访问的数据库中。默认情况下,它通过使用 lab123it/aws-sns 包通过 AWS SNS 发送通知。

使用场景

如果您有一些微服务并希望有集中式审计,这可能很有用。

要求

  • PHP >= 7.1
  • Laravel >= 5.2 && < 5.8

安装

步骤 1

此包依赖于 owen-it/laravel-auditing:^8.0lab123it/aws-sns:dev-master,因此您必须首先安装和配置它们才能使其正常工作。

您可以通过 composer 安装此包

composer require andreshg112/laravel-auditing-notifications

步骤 2

更改审计默认驱动程序

return [
    // ...
    /*
    |--------------------------------------------------------------------------
    | Audit Driver
    |--------------------------------------------------------------------------
    |
    | The default audit driver used to keep track of changes.
    |
    */

    'driver' => Andreshg112\LaravelAuditingNotifications\NotificationDriver::class,
];

您可以在模型上本地进行此操作。请参阅文档:http://laravel-auditing.com/docs/8.0/audit-drivers

步骤 3

在您的 config/audit.php 文件中,添加以下内容

return [
    // ...

    // andreshg112/laravel-auditing-notifications

    'notification-driver' => [
        // Required if you're going to use different notifications channels for sending audit data.
        'notifications' => [
            Andreshg112\LaravelAuditingNotifications\AuditSns::class,

            // Or this if you want to queue the delivery of the message.
            // https://laravel.net.cn/docs/5.2/queues
            // Andreshg112\LaravelAuditingNotifications\AuditSnsQueue::class,
        ],

        // Required if you're going to use the default Andreshg112\LaravelAuditingNotifications\AuditSns Notification.
        'sns' => [
            'topic_arn' => 'arn:aws:sns:us-east-1:xxxxxxxxxxxx:auditing-notifications',
        ],
    ],
];

用法

Illuminate\Notifications\Notifiable 特性添加到您想要审计的模型中,除了 Auditable 协议和特性。

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class Vehicle extends Model implements \OwenIt\Auditing\Contracts\Auditable
{
    use \OwenIt\Auditing\Auditable, Notifiable;
}

就这么多!只需在模型上执行一个 可审计事件,以发送通知。

测试

composer test

变更日志

请参阅 发布 以获取更多关于最近更改的信息。

贡献

请参阅 CONTRIBUTING 获取详细信息。

安全

如果您发现任何安全问题,请通过电子邮件 andreshg112@gmail.com 而不是使用问题跟踪器。

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件

Laravel 包模板

此包是使用 Laravel 包模板 生成的。