PHPackages                             inisiatif/laravel-event-history - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. inisiatif/laravel-event-history

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

inisiatif/laravel-event-history
===============================

Record event as history

0.5.0(2y ago)09.7k↑183.3%[2 PRs](https://github.com/atInisiatifZakat/laravel-event-history/pulls)MITPHPPHP ^8.1

Since Aug 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/atInisiatifZakat/laravel-event-history)[ Packagist](https://packagist.org/packages/inisiatif/laravel-event-history)[ Docs](https://github.com/atInisiatifZakat/laravel-event-history)[ RSS](/packages/inisiatif-laravel-event-history/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (5)Dependencies (5)Versions (8)Used By (0)

Record event as history
=======================

[](#record-event-as-history)

[![Latest Version on Packagist](https://camo.githubusercontent.com/df6e4979c329481a73d9deeeba13c2ce07c7d146a9938218042dc1a07cfd631b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e697369617469662f6c61726176656c2d6576656e742d686973746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/inisiatif/laravel-event-history)[![PHPUnit](https://github.com/atInisiatifZakat/laravel-event-history/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/atInisiatifZakat/laravel-event-history/actions/workflows/run-tests.yml)[![Laravel Pint](https://github.com/atInisiatifZakat/laravel-event-history/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/atInisiatifZakat/laravel-event-history/actions/workflows/fix-php-code-style-issues.yml)[![Psalm](https://github.com/atInisiatifZakat/laravel-event-history/actions/workflows/run-psalm-static-analyst.yml/badge.svg?branch=main)](https://github.com/atInisiatifZakat/laravel-event-history/actions/workflows/run-psalm-static-analyst.yml)[![Total Downloads](https://camo.githubusercontent.com/26d3d320a4429e4f6ea8c05192610801aba7d8b5703d277712a35a4cbfc50f94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e697369617469662f6c61726176656c2d6576656e742d686973746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/inisiatif/laravel-event-history)

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

Installation
------------

[](#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
-----

[](#usage)

### Persiapan

[](#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

[](#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`

```
