inisiatif/laravel-event-history

Record event as history
10,327
Install
composer require inisiatif/laravel-event-history
Latest Version:0.5.0
PHP:^8.1
Laravel:10 – 13
License:MIT
Last Updated:Oct 9, 2023
Links: GitHub  ·  Packagist
Maintainer: NoorAdiana

Record event as history

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.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

399,241,428 4,660

Version History

Version Released PHP License
0.5.0 ^8.1 MIT
0.4.0 ^8.1 MIT
0.3.0 ^8.1 MIT
0.2.0 ^8.1 MIT
0.1.0 ^8.1 MIT