PHPackages                             thtg88/journalism - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. thtg88/journalism

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

thtg88/journalism
=================

Journalism is a Laravel package providing a simple way to log data to your database

v0.7.0(3mo ago)011.7k↑66.7%1MITPHPPHP ^8.2CI failing

Since Mar 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/thtg88/journalism)[ Packagist](https://packagist.org/packages/thtg88/journalism)[ RSS](/packages/thtg88-journalism/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (13)Used By (1)

Journalism
==========

[](#journalism)

Journalism is a Laravel package providing a simple way to log data to your database.

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

[](#installation)

```
composer require thtg88/journalism
```

You can publish the configuration file and views by running:

```
php artisan vendor:publish --provider="Thtg88\Journalism\JournalismServiceProvider"
```

Usage
-----

[](#usage)

Journalism is particularly useful when tracking changes to models.

You can therefore apply it to either a generic model observer for every model event (create, update, and destroy) or, if you use the repository pattern to all your CRUD methods to track what, when, and by whom certain changes have occurred.

Make sure you register the helper as a singleton in your `AppServiceProvider`:

```
// app/Providers/AppServiceProvider.php

use Thtg88\Journalism\Helpers\JournalEntryHelper;

public function register(): void
{
    $this->app->singleton(JournalEntryHelper::class, static function ($app) {
        return $app->make(JournalEntryHelper::class);
    });
}
```

Or you can simply use it in whichever class you prefer:

```
use Thtg88\Journalism\Helpers\JournalEntryHelper;

(new JournalEntryHelper())->createJournalEntry('create', $model, ['foo' => 'bar']);
```

### Using Model Observers

[](#using-model-observers)

For more documentation on model observer, see the [Laravel docs](https://laravel.com/docs/8.x/eloquent#observers)

First, create a base model observer:

```
