Code Monkey home page Code Monkey logo

nova-activitylog's Introduction

Nova tool for activity log

StyleCI Packagist Downloads Packagist Version GitHub FOSSA Status

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="activitylog-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 the backend uses the spatie/laravel-activitylog package, you need to 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

Authorizing

Typical usage of tool authorizing using ->canSee() or ->canSeeWhen() when registering the tool will NOT work. To authorize the tool, simply make and register a Laravel policy for the ActivityLog model. If a user is not able to view them according to the policy, the tool will not show.

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.

FOSSA Status

nova-activitylog's People

Contributors

bolechen avatar fossabot avatar godwillcodes avatar henryavila avatar joeyrush avatar kussie avatar milewski avatar mtawil avatar qskousen avatar vgirol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nova-activitylog's Issues

Duplicate "Activity Logs" entry in the menu

Hi there,

In the documentation it only shows "Activity Logs" in the menu once, but in my case it also appears within Resources. Is this expected?
I would like only the bottom one to appear.
Thanks.

Screenshot 2023-11-24 at 09 24 41

Can We get more details info

Nice article.

Can We get more details information like Who do changes, email etc.

Those are really helpful.
Thanks

Your requirements could not be resolved to an installable set of packages.

composer update

  Problem 1
    - Root composer.json requires bolechen/nova-activitylog ^0.2.1 -> satisfiable by bolechen/nova-activitylog[v0.2.1].
    - bolechen/nova-activitylog v0.2.1 requires laravel/nova ^2.0|^3.0 -> satisfiable by laravel/nova[3.x-dev (alias of dev-master)] from lock repo but laravel/nova[dev-develop] from path repo (./nova) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.
  Problem 2
    - nemrutco/nova-filterable-metrics[v1.1.0, ..., v1.1.4] require laravel/nova >=2.0 -> satisfiable by laravel/nova[3.x-dev (alias of dev-master)] from lock repo but laravel/nova[dev-develop] from path repo (./nova) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.
    - Root composer.json requires nemrutco/nova-filterable-metrics ^1.1 -> satisfiable by nemrutco/nova-filterable-metrics[v1.1.0, ..., v1.1.4].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Nothing will be logged

It seems that i missed some settings because nothing will be logged. I thought that your package log alle activities on all resources?!

Nova Menu entry visible locally but not on staging

Ahoy there

I didn't find the same question hence me asking now: I am facing the issue that I can see the Actitiy Log menu in Nova 4 fine locally
image

But as soon as I am uploading it (via Vapor), the menu entry is gone and trying to access it directly leads to a 404.

I do not see any configuration or value which could cause this here, but maybe I am missing something.

I just added it as Tools, as in the README, and locally all is fine. I just am lacking an idea why it won't show up on staging.

Does anybody has an idea or hint where to look for?

Thanks a lot

Override Activitylog resource

Hi! Thanks a lot for this nova package!
Could you please help me to override your Activitylog resource? Trying within NovaServiceProvider or my custom service provider - no success...
I would override fields method to output user name instead of id, but can't find the way. Maybe you could help...

Thanks!

Field MorphTo::make('Causer', 'causer') not displaying anything.

In fields for the ActivityLog resource: MorphTo::make('Causer', 'causer'), doesn't return a displayable value. It simply shows a dash for all activities. Meanwhile the database has the correct causer type and causer id.

Did you need to add anything to the user model to accept the relationship? or to the Nova User resource?

Disable this package outside of Nova?

I only want to use the package to display activities in Nova, not to actually log anything. Is it possible to not have the package interact with my front end app?

I get this error when I switched to use my own model with activity logger. Ideas? Thanks!

Bolechen\NovaActivitylog\ToolServiceProvider::Bolechen\NovaActivitylog\{closure}(): Argument #1 ($activity) must be of type Spatie\Activitylog\Models\Activity, App\Models\Activity given, called in /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 421

Recording Log Ins

Is there an easy way to record nova log ins?

There's no obvious auth classes for nova.

How to add filters?

I've made a local resource by extending your class,
e.g. class ActivityLog extends \Bolechen\NovaActivitylog\Resources\Activitylog
to try and override the filters function to add my own filter.

How do I get your nova tool to use my local ActivityLog (with filters) instead of the one in your package?

Can't change sidebar label

Sidebar label not changing with

public static function label(){}

Page title however is respecting this method override.

Adding the Activity Log relation to the Nova User resource

Thanks for the package.

Question, is there an easy way to add the Activity log relation ship to the Nova User resource based on the user model so that we can see all activity log of the user when going to the user details view. Thanks!

How to track changes through the model's static::creating() method?

How to track changes through the model's static::creating() method?

The sample code from the model, logic execution and data change in the database is not tracked here:

public static function boot()
    {
        parent::boot();

        static::creating(function (Cost $cost) {
         // 
                User::update[
                //
                ];
        }
  }

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.