inisiatif / laravel-event-history
Record event as history
Installs: 6 086
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: ^8.1
- spatie/laravel-package-tools: ^1.16.0
Requires (Dev)
- laravel/pint: ^1.10
- orchestra/testbench: ^8.0
- roave/security-advisories: dev-latest
- vimeo/psalm: ^5.0
This package is auto-updated.
Last update: 2024-11-09 11:09:04 UTC
README
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.