julesgraus/actionlogs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

julesgraus/actionlogs

最新稳定版本:1.0.0

Composer 安装命令:

composer require julesgraus/actionlogs

包简介

Tools for logging actions

README 文档

README

Log any actions users do in your Laravel application.

Installation

You can install the package via composer:

composer require julesgraus/actionlogs

Usage

Direct logging

You can log actions directly like so:

JulesGraus\Actionlogs\Actionlogs::log('your action', 'a payload');

The logged action wil be linked to the authenticated user if any. The payload can be anything but a resource.

Automatic logging

The package listens to some events in the Illuminate\Auth\Events namespace by default and automatically logs those. This is a list of those events:

  • Login
  • Logout
  • Failed
  • Lockout
  • Registered
  • PasswordReset
  • Verified

You can listen to extra events if you would like to. You could for example do that like so:

JulesGraus\Actionlogs\Actionlogs::listenToAndLog(MyCustomEvent::class, fn(MyCustomEvent::class $event) => 'Logging something for my customevent: '.$event->user->email)

Put that line of code in the register method of a service provider in your implementation.

Housekeeper

The package is compatible with julesgraus/housekeeper. Register the JulesGraus\Actionlogs\Actionlogs class to the housekeeper and read the published config options for more info.

Customisation

Configuration and localisation

publish the config files and translation file of this package by running php artisan vendor:publish --tag=actionlogs. You can then edit the config file that will be put in the config dir. And the translations that are put in resources/lang/vendor/actionlogs

Overriding the default Actionlog model

When the default actionlog model from this package does not provide the functionality you want, you can create a custom model yourself.

Just make sure it implements JulesGraus\Actionlogs\Contracts\Actionlog and then register it to Laravel's container in the register method of a service provider like so:

use Illuminate\Support\ServiceProvider;
use App\Actionlogs\MyCustomActionLog;
use JulesGraus\Actionlogs\Contracts\Actionlog as ActionlogContract;

class AppServiceProvider extends ServiceProvider {
    register() {
        $this->app->bind(ActionlogContract::class, MyCustomActionlog::class);
    }
}

Also make sure your custom implementation can accept any variable type for the payload attribute except a resource type.

Overriding other stuff

Like the actionlog model you can also override other stuff by implementing and registering these interfaces in the JulesGraus\Actionlogs\Contracts namespace:

  • ActionlogPolicy
  • ActionlogResource
  • ActionlogResourceCollection

Please bind resources and collections to a function that returns the class name of an implementation. Else Laravel will try to instantiate the classes and nag about the resource parameter that it cannot resolve.

Testing

Run tests by running this command in the root of the package.

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-03-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固