inisiatif/laravel-event-history 问题修复 & 功能扩展

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

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

inisiatif/laravel-event-history

最新稳定版本:0.5.0

Composer 安装命令:

composer require inisiatif/laravel-event-history

包简介

Record event as history

README 文档

README

Latest Version on Packagist PHPUnit Laravel Pint Psalm Total Downloads

Paket ini digunakan untuk mencatan event seperti Pengajuan sudah di setujui dll.

Installation

You can install the package via composer:

composer require inisiatif/laravel-event-history

You can publish and run the migrations with:

php artisan vendor:publish --tag="event-history-migrations"
php artisan migrate

Usage

Persiapan

Melakukan registrasi user model, tambahkan code berikut di boot method AppServiceProvider

use Inisiatif\EventHistory\EventHistories;

EventHistories::useUserModelClassName(User::class);

Selanjutnya semua model yang mempunyai history harus implement interface Inisiatif\EventHistory\Concerns\HasEventHistories, kita juga bisa menggunakan default implementasi dengan trait Inisiatif\EventHistory\InteractWithEventHistories

use Illuminate\Database\Eloquent\Model;
use Inisiatif\EventHistory\Concerns\HasEventHistories;
use Inisiatif\EventHistory\InteractWithEventHistories;

class ExampleModel extends Model implements HasEventHistories {
    use InteractWithEventHistories;
}

Menggunakan Listener

Anda bisa menggukakan Inisiatif\EventHistory\RecordEventHistoryListener untuk setiap event yang akan di catat history-nya, yang perlu di pastikan adalah event anda harus implements Inisiatif\EventHistory\Concerns\EventHistoryAwareInterface

<?php

declare(strict_types=1);

namespace Inisiatif\EventHistory\Concerns;

interface EventHistoryAwareInterface
{
    public function getModelAwareHistories(): mixed;

    public function getHistoryDescription(): string;
}

method getModelAwareHistories harus return model atau collection dengan interface Inisiatif\EventHistory\Concerns\HasEventHistories. Under the hood, listener akan memanggil job Inisiatif\EventHistory\Jobs\NewEventHistoryJob

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.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-30