Laravel User Activity


User activity monitoring is very important when your application uses multiple people and you need to know user login activity, lockout activity for too many login attempts and existing data editing and deleting logs. Developing such as user activity monitoring system is quite a time consuming and not an easy task. If you are finding a flexible and easy way to monitor your application user activity then Laravel User Activity is the free package for that, which help you to monitor your application user activity very easily with beautiful, responsive and easy user-interface. Let's take a look at what are the features of Laravel user activity package.

 

Features of Laravel User Activity

  • Beautiful, responsive and easy UI.
  • Easy installation to existing or new Laravel application.
  • Monitor record edit, record delete, login and lockout activity.
  • Filtering user activity logs.
  • Configurable routes.
  • Custom middleware support.
  • Console command for activity log clear.

 

Installation

Step 1 Run this command given below for install the laravel user activity package.

composer require haruncpi/laravel-user-activity

Step 2 Now run this artisan command.

php artisan user-activity:install

Installation finished!

 

Usages

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 your existing table record edit and delete, just use the Loggable trait into 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 user deleted or edited.

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Haruncpi\LaravelUserActivity\Traits\Loggable;

class Student extends Model
{
    use Loggable;

} 

 

activity-log-details-preview.png

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.

http://example.com/admin/user-activity

Dashboard Preview

user-activity-dashboard.png

Available console command

To delete activity log data older than defined days value into the user-activity.php config file (default value: 7 days).

php artisan user-activity:delete

To delete activity log data older than n days.

php artisan user-activity:delete 30

To delete all activity log data

php artisan user-activity:delete all

N.B With the help of these console commands, you can make laravel schedule for deleting user activity log data automatically. If you are shared hosting (cPanel) user then you can read laravel schedule in the shared hosting tutorial post.

Customization

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.

<?php

return [
    'middleware'       => ['web', 'auth'],
    'route_path'       => 'admin/user-activity',
    'admin_panel_path' => 'admin/dashboard',
    'delete_limit'     => 7,

    'log_events' => [
        'on_edit'    => true,
        'on_delete'  => true,
        'on_login'   => true,
        'on_lockout' => true
    ]
];

 

Hope this package will help you to monitor your application user activity with 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 GitHub repository to make it better.

 

Share on



Social Links


Related Post - Latest Post


Laravel Barcode generation tutorial

Laravel Breeze - Starting with Laravel has been easy!

Laravel API mailer

Laravel H package

Laravel Simple Filemanager

Laravel Option Framework