sudippalash/activity-log

Laravel package for Activity log

1.0.1 2024-11-02 20:48 UTC

This package is auto-updated.

Last update: 2024-11-02 20:49:58 UTC


README

alt text

Latest Version on Packagist Total Downloads

activity-log is a activity log management package of Laravel that provides options to create & manage activity log.

Note: This package is wrapper of spatie/laravel-activitylog package.

Install

Via Composer

composer require sudippalash/activity-log

Publish config & migrations files

You should publish

migrations files:

  1. database/migrations/create_activity_log_table.php
  2. database/migrations/add_event_column_to_activity_log_table.php,
  3. database/migrations/add_batch_uuid_column_to_activity_log_table.php,

config files:

  1. config/activitylog.php,
  2. config/activity-log.php

with:

php artisan vendor:publish --provider="Sudip\ActivityLog\Providers\AppServiceProvider" --tag=required

For config/activitylog.php file you should check spatie/laravel-activitylog package documentation.

This is the contents of the published config file config/activity-log.php:

    return [
        /*
        |--------------------------------------------------------------------------
        | Extends Layout Name
        |--------------------------------------------------------------------------
        |
        | Your main layout file path name. Example: layouts.app
        | 
        */

        'layout_name' => 'layouts.app',
        
        /*
        |--------------------------------------------------------------------------
        | Section Name
        |--------------------------------------------------------------------------
        |
        | Your section name which in yield in main layout file. Example: content
        | 
        */

        'section_name' => 'content',

        /*
        |--------------------------------------------------------------------------
        | Route Name, Prefix & Middleware
        |--------------------------------------------------------------------------
        |
        | Provide a route name for activity-log route. Example: user.activity-logs
        | Provide a prefix name for activity-log url. Example: user/activity-logs
        | If activity-log route use any middleware then provide it or leave empty array. Example: ['auth'] 
        */

        'route_name' => 'user.activity-logs',
        'route_prefix' => 'user/activity-logs',
        'middleware' => [],

        /*
        |--------------------------------------------------------------------------
        | Bootstrap version
        |--------------------------------------------------------------------------
        |
        | Which bootstrap you use in your application. Example: 3 or 4 or 5
        | 
        */

        'bootstrap_v' => 5,

        /*
        |--------------------------------------------------------------------------
        | CSS
        |--------------------------------------------------------------------------
        |
        | Add your css class in this property if you want to change design. 
        */

        'css' => [
            'container' => null,
            'card' => null,
            'input' => null,
            'btn' => null,
            'table' => null,
            'table_action_col_width' => null,
            'table_action_btn' => null,
        ],
    ];

Optionally, you can publish the views using

php artisan vendor:publish --provider="Sudip\ActivityLog\Providers\AppServiceProvider" --tag=views

Optionally, you can publish the lang using

php artisan vendor:publish --provider="Sudip\ActivityLog\Providers\AppServiceProvider" --tag=lang

You should run the migrations with:

php artisan migrate

Usage

You should copy the below line and paste in your project menu section

<a href="{{ route(config('activity-log.route_name') . '.index') }}">{{ trans('activity-log::sp_activity_log.activity_logs') }}</a>

Use this `ActivityLog`` trait in your model(s). It will automatically store all DB-related events to the model(s).

use Sudip\ActivityLog\Traits\ActivityLog;

class User extends Authenticatable
{
    use ActivityLog;

    ...
}