承接 fikrimastor/audit-login 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

fikrimastor/audit-login

最新稳定版本:v1.1.1

Composer 安装命令:

composer require fikrimastor/audit-login

包简介

Audit login is a another package for laravel framework. The purpose is to auditing login events

README 文档

README

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

Audit login is another package for Laravel framework. The purpose is auditing login events

Support us

Installation

You can install the package via composer:

composer require fikrimastor/audit-login

You can publish and run the migrations with:

php artisan vendor:publish --tag="audit-login-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="audit-login-config"

This is the contents of the published config file:

return [
    'enabled' => env('AUDIT_LOGIN_ENABLED', true),
    'drivers' => [
        'database' => [
            'table' => env('AUDIT_LOGIN_DATABASE_TABLE', 'audit-logins'),
            'connection' => env('AUDIT_LOGIN_DATABASE_CONNECTION', 'mysql'),
        ],
    ],
    ...
];

Usage

If you want to custom some actions, for example, while user login, you want to send an email notification, you may create new service provider and defined it in config/app.php.

So, under the new service provider, under the boot method, you can do something like this:

use \FikriMastor\AuditLogin\Facades\AuditLogin;
use \YourProjectNamespace\YourCustomLoginEventClass;

public function boot(): void
{
    AuditLogin::recordLoginUsing(YourCustomLoginEventClass::class);
}

And then, you can create a new class for your custom login event action class, for example:

use \FikriMastor\AuditLogin\Contracts\LoginEventContract;

class YourCustomLoginEventClass implements LoginEventContract
{
    public function handle(object $event, AuditLoginAttribute $attributes): void
    {
        AuditLogin::auditEvent($event, $attributes);
        
        // Do something here
        
        // Send email notification
        
        
    }
}

The event object consists of the user object logged in, and the attribute object is the object that contains the login event attributes.

Some of it use Authenticatable contract, so you can use it to get the user data.

You may learn about Auth events in Laravel here.

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.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-08