PHPackages                             hanifhefaz/user-model-activity - 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. hanifhefaz/user-model-activity

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

hanifhefaz/user-model-activity
==============================

Log activities over models into a log file.

1.0.0(2y ago)48MITPHP

Since Oct 15Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

User Model Activity
-------------------

[](#user-model-activity)

[![](https://camo.githubusercontent.com/539bf60c131474f17dbd68b6eb87522c3feee3368a21078941aae22c5dfa15e1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f557365722532304d6f64656c25323041637469766974792e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d68616e6966686566617a253246757365722d6d6f64656c2d6163746976697479267061747465726e3d696e74657273656374696e67436972636c6573267374796c653d7374796c655f31266465736372697074696f6e3d547261636b2b6d6f64656c732532372b637265617465642532432b757064617465642b616e642b64656c657465642b6163746976697479266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313530707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667267769647468733d34303026686569676874733d343030)](https://camo.githubusercontent.com/539bf60c131474f17dbd68b6eb87522c3feee3368a21078941aae22c5dfa15e1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f557365722532304d6f64656c25323041637469766974792e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d68616e6966686566617a253246757365722d6d6f64656c2d6163746976697479267061747465726e3d696e74657273656374696e67436972636c6573267374796c653d7374796c655f31266465736372697074696f6e3d547261636b2b6d6f64656c732532372b637265617465642532432b757064617465642b616e642b64656c657465642b6163746976697479266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313530707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667267769647468733d34303026686569676874733d343030)

- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [Conclusion](#conclusion)
- [Contributors](#contributors)
- [Known Issues and future plans](#issues-plans)

Introduction
------------

[](#introduction)

Introducing the User Model Activity Package: Effortlessly Track Changes in Your Models

Have you ever found yourself in need of a simple yet effective way to track and log changes made to your Laravel models? Look no further! We are thrilled to present our User Model Activity package, designed to save the logs of model events such as creation, update, and deletion into a convenient log file. With this package, monitoring and auditing changes in your application's models has never been easier.

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

[](#installation)

You can install the package with Composer.

```
composer require hanifhefaz/user-model-activity
```

After installation run the following command to publish the necessary assets and files:

```
php artisan vendor:publish --provider="Hanifhefaz\UserModelActivity\UserModelActivityServiceProvider"
```

That's it. You have successfully installed and published the required files and assets of the package.

Usage
-----

[](#usage)

Once you have installed and configured the package, you can start using it to track changes in your models. Follow this step-by-step guide to get started:

- Logging File Configuration

    First things is first! Go to your `config/logging.php` and add the following to the channels array:

    ```
    /*
    * Logging.php
    */
        'channels' => [
            // existing code ...

            // 'stack' => [
            //     'driver' => 'stack',
            //     'channels' => ['single'],
            //     'ignore_exceptions' => false,
            // ],

            // ...

            'user-model-activity' => [
                'driver' => 'single',
                'path' => storage_path('logs/user-model-activity.log'),
                'level' => 'debug',
            ],
        ]
    ```

    Now, you can use the `UserModelActivityLogger` trait inside the model and all the logs will be tracked.

    ```
