Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hanifhefaz/user-model-activity
https://github.com/hanifhefaz/user-model-activity
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hanifhefaz/user-model-activity
- Owner: hanifhefaz
- License: mit
- Created: 2023-10-15T06:40:24.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-15T06:43:05.000Z (about 1 year ago)
- Last Synced: 2024-04-17T13:20:37.185Z (7 months ago)
- Language: PHP
- Size: 152 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## User Model Activity
- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [Conclusion](#conclusion)
- [Contributors](#contributors)
- [Known Issues and future plans](#issues-plans)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.
You can install the package with Composer.
```bash
composer require hanifhefaz/user-model-activity
```After installation run the following command to publish the necessary assets and files:
```shell
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.
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:
```php
/*
* 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.
```php
## ConclusionThe User Model Activity package offers a straightforward and efficient solution for tracking changes made to your Laravel models. It simplifies the process of monitoring, auditing, and debugging model-related changes. Enhance your application's maintainability and gain valuable insights into your data with the User Model Activity package.
Contributions are most welcome! Please pick one of the known issues and future plans or implement your own idea to help the package grow.
Current Contributers: [Contributors](https://github.com/hanifhefaz/user-model-activity/graphs/contributors).
## Known issues and future plans- To further enhance the package, we plan to bring some changes in the log views. currently its not optimized.
- A better approach to integrate user's details as well to the log. currently it will save details of model, and if your model has created_by it will be logged, but we need a better approach for this.
- Parsing of the logs in a better way.
- The trait is not working in spatie's Role and Permission models if they are extended from parent model such as below:
```php