sudippalash/activity-log

Laravel package for Activity log preview

1.0.3 2024-12-15 16:23 UTC

This package is auto-updated.

Last update: 2025-02-15 16:44:27 UTC


README

alt text

Latest Version on Packagist Total Downloads

activity-log is an activity log management package for Laravel that allows you to create and preview activity logs.

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 MyModel extends Model
{
    use ActivityLog;

    ...
}