Giter VIP home page Giter VIP logo

nova-activitylog's Introduction

Nova tool for activity log

StyleCI Packagist Downloads Packagist Version GitHub

A tool to activity logger to monitor the users of your Laravel Nova.

screenshot

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require bolechen/nova-activitylog

You can publish the migration with:

php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="migrations"

Note: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject_id and causer_id fields in the published migration before continuing.

After publishing the migration you can create the activity_log table by running the migrations:

php artisan migrate

You can optionally publish the config file with:

php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"

You may only want to log actions from nova, put this line to your .env files let default logger off.

ACTIVITY_LOGGER_ENABLED=false

How to use

Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvder.php

// ...

public function tools()
{
    return [
        // ...
        new \Bolechen\NovaActivitylog\NovaActivitylog(),
    ];
}

Because backend we use the spatie/laravel-activitylog package, you need to do is let your model use the Spatie\Activitylog\Traits\LogsActivity trait.

Here's an example:

use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;

class NewsItem extends Model
{
    use LogsActivity;

    protected $fillable = ['name', 'text'];
    
    protected static $logAttributes = ['name', 'text'];
}

For more advanced usage can look at the doc: https://docs.spatie.be/laravel-activitylog/v3/advanced-usage/logging-model-events

Customize

If you want to customize the tools. Eg: add filters or cards, you can create your owner resource file extends the original like this:

use Bolechen\NovaActivitylog\Resources\Activitylog;

class Activity extends Activitylog
{
    public function filters(Request $request)
    {
        return [
            // Your customize filters, etc...
            new Filters\LogsType(),
        ];
    }
}

Next up, publish the config file with:

php artisan vendor:publish --provider="Bolechen\\NovaActivitylog\\ToolServiceProvider" --tag="config"

And change the resource in config/nova-activitylog.php to your custom nova resource.

License

The MIT License (MIT). Please see License File for more information.

nova-activitylog's People

Contributors

bolechen avatar henryavila avatar mtawil avatar milewski avatar schrink avatar joeyrush avatar

Watchers

James Cloos avatar

Forkers

dramaonline-nl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.