|
1 |
| -<h1 align="center">Laravel User Activity</h1> |
2 |
| -<p align="center"><a href="https://packagist.org/packages/haruncpi/laravel-user-activity"><img src="https://badgen.net/packagist/v/haruncpi/laravel-user-activity" /></a> |
3 |
| - <a href="https://creativecommons.org/licenses/by/4.0/"><img src="https://badgen.net/badge/licence/CC BY 4.0/23BCCB" /></a> |
4 |
| - <a href=""><img src="https://badgen.net/packagist/dt/haruncpi/laravel-user-activity"/></a> |
5 |
| - <a href="https://twitter.com/laravelarticle"><img src="https://badgen.net/badge/twitter/@laravelarticle/1DA1F2?icon&label" /></a> |
6 |
| - <a href="https://facebook.com/laravelarticle"><img src="https://badgen.net/badge/facebook/laravelarticle/3b5998"/></a> |
7 |
| -</p> |
| 1 | +Features of Laravel User Activity |
| 2 | +--------------------------------- |
8 | 3 |
|
9 |
| -<p align="center">Easily monitor your user activity with beautiful responsive & easy user-interface!</p> |
| 4 | +* Beautiful, responsive and easy UI. |
| 5 | +* Easy installation to existing or new Laravel application. |
| 6 | +* Monitor record edit, record delete, login and lockout activity. |
| 7 | +* Filtering user activity logs. |
| 8 | +* Configurable routes. |
| 9 | +* Custom middleware support. |
| 10 | +* Console command for activity log clear. |
10 | 11 |
|
11 |
| - |
| 12 | +Installation |
| 13 | +------------ |
12 | 14 |
|
13 |
| -## Documentation |
14 |
| -Checkout features & full documentation of [Laravel User Activity](https://laravelarticle.com/laravel-user-activity) |
| 15 | +Step 1 Run this command given below to install the laravel user activity package. |
15 | 16 |
|
16 |
| -## Other Packages |
17 |
| -- [Laravel H](https://github.com/haruncpi/laravel-h) - A helper package for Laravel Framework. |
18 |
| -- [Laravel ID generator](https://github.com/haruncpi/laravel-id-generator) - A laravel package for custom database ID generation. |
19 |
| -- [Laravel Simple Filemanager](https://github.com/haruncpi/laravel-simple-filemanager) - A simple filemanager for Laravel. |
20 |
| -- [Laravel Option Framework](https://github.com/haruncpi/laravel-option-framework) - Option framework for Laravel. |
| 17 | +``` |
| 18 | +composer require haunv/laravel-user-activity |
| 19 | +``` |
21 | 20 |
|
22 |
| -### Change Log |
23 | 21 |
|
24 |
| -v1.0.6 |
25 |
| -- Default user model `App\Models\User` to support laravel >=8 |
26 |
| -- Carbon date parse instead of $dates cast. |
| 22 | +Step 2 Now run this artisan command. |
27 | 23 |
|
28 |
| -v1.0.4 |
29 |
| -- Completely enable or disable logging by `activated` config value |
30 |
| -- Added Base model logging compatibility |
| 24 | +``` |
| 25 | +php artisan user-activity:install |
| 26 | +``` |
31 | 27 |
|
32 |
| -v1.0.3 |
33 |
| -- Minor improvements |
34 | 28 |
|
35 |
| -v1.0.2 |
36 |
| -- Create log type added |
37 |
| -- User model configuration |
38 |
| -- UI ajax loading indicator |
| 29 | +Installation finished! |
| 30 | + |
| 31 | +Usages |
| 32 | +------ |
| 33 | + |
| 34 | +By default, It will catch login activity and lockout (too many attempts) automatically. You can enable or disable it by config value. To keep track of your existing table record edit and delete, just use the `Loggable` trait in your model. That's it, super simple! If any user edits or delete your existing table record, it will automatically be logged into the `logs` table and you will get the details, what data deleted or edited by users. |
| 35 | + |
| 36 | +``` |
| 37 | +<?php namespace App; |
| 38 | +
|
| 39 | +use Illuminate\Database\Eloquent\Model; |
| 40 | +use Haruncpi\LaravelUserActivity\Traits\Loggable; |
| 41 | +
|
| 42 | +class Student extends Model |
| 43 | +{ |
| 44 | + use Loggable; |
| 45 | +
|
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +To view user activity dashboard, browse the `/admin/user-activity`. By default, only logged in user can view the user activity dashboard. You can add any middleware restriction by `user-activity.php` config file. |
| 53 | + |
| 54 | +``` |
| 55 | +http://example.com/admin/user-activity |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | +**Dashboard Preview** |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +Available console command |
| 64 | +------------------------- |
| 65 | + |
| 66 | +To delete activity log data older than defined days value into the `user-activity.php` config file (default value: 7 days). |
| 67 | + |
| 68 | +``` |
| 69 | +php artisan user-activity:delete |
| 70 | +``` |
| 71 | + |
| 72 | + |
| 73 | +To delete activity log data older than n days. |
| 74 | + |
| 75 | +``` |
| 76 | +php artisan user-activity:delete 30 |
| 77 | +``` |
| 78 | + |
| 79 | + |
| 80 | +To delete all activity log data |
| 81 | + |
| 82 | +``` |
| 83 | +php artisan user-activity:delete all |
| 84 | +``` |
| 85 | + |
| 86 | + |
| 87 | +N.B With the help of these console commands, you can make a laravel schedule for deleting user activity log data automatically. If you are a shared hosting (cPanel) user then you can read the [laravel schedule in the shared hosting](https://laravelarticle.com/laravel-scheduler-on-cpanel-shared-hosting) tutorial post. |
| 88 | + |
| 89 | +Customization |
| 90 | +------------- |
| 91 | + |
| 92 | +Change the config value according to your need into the `user-activity.php` config file to customize activity log dashboard URL, custom middleware and activity log enable or disable. Default config values are given below. |
| 93 | + |
| 94 | +``` |
| 95 | +<?php |
| 96 | +
|
| 97 | +return [ |
| 98 | + 'activated' => true, |
| 99 | + 'middleware' => ['web', 'auth'], |
| 100 | + 'route_path' => 'admin/user-activity', |
| 101 | + 'admin_panel_path' => 'admin/dashboard', |
| 102 | + 'delete_limit' => 7, |
| 103 | +
|
| 104 | + 'model' => [ |
| 105 | + 'user' => "App\User" |
| 106 | + ], |
| 107 | +
|
| 108 | + 'log_events' => [ |
| 109 | + 'on_edit' => true, |
| 110 | + 'on_delete' => true, |
| 111 | + 'on_login' => true, |
| 112 | + 'on_lockout' => true |
| 113 | + ] |
| 114 | +]; |
| 115 | +``` |
| 116 | + |
| 117 | + |
| 118 | +Note: You can configure your user instance. For Laravel 8, use it `App\Models\User` |
| 119 | + |
| 120 | +Hope this package will help you to monitor your application user activity with a beautiful and easy UI. The laravel user activity package is an open-source laravel package with CC 4.0 licence. Support the [Laravel User Activity package](https://github.com/haruncpi/laravel-user-activity) GitHub repository to make it better. |
| 121 | + |
| 122 | +### Base Model Class Configuration |
| 123 | + |
| 124 | +Suppose, you have a parent model class extends by the laravel eloquent model class and it has a lot of sub-class. In this situation, you can easily configure the Larave User Activity package with your base model class implementation. |
| 125 | + |
| 126 | +Use Loggable trait In your base model class |
| 127 | + |
| 128 | +``` |
| 129 | +class BaseModel extends Model |
| 130 | +{ |
| 131 | + use Loggable; |
| 132 | + |
| 133 | + ... |
| 134 | + ... |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | + |
| 139 | +Now all the sub-class of the base model will be automatically logged! In case, If you don't want to log for any subclass of the base model just add a property to exclude logging. |
| 140 | + |
| 141 | +``` |
| 142 | +class B extends BaseModel |
| 143 | +{ |
| 144 | + public $excludeLogging = true; |
| 145 | + ... |
| 146 | + ... |
| 147 | +} |
| 148 | +``` |
0 commit comments