Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

View your Spatie Laravel activity logs inside of Filament.

License

Notifications You must be signed in to change notification settings

alexjustesen/filament-spatie-laravel-activitylog

Repository files navigation

View your activity logs inside of Filament.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a Filament resource that shows you all of the activity logs created using the spatie/laravel-activitylog package. It also provides a relationship manager for related models.

Installation

Warning

Version ^0.7 supports Filament v3.

You can install the package via composer:

// For Filament v3
composer require alexjustesen/filament-spatie-laravel-activitylog:^0.7

// For Filament v2
composer require alexjustesen/filament-spatie-laravel-activitylog:^0.6

You can publish the config file with:

php artisan vendor:publish --tag="filament-spatie-activitylog-config"

This is the contents of the published config file:

return [

    'resource' => [
        'filament-resource' => AlexJustesen\FilamentSpatieLaravelActivitylog\Resources\ActivityResource::class,
        'group' => null,
        'sort'  => null,
    ],

    'paginate' => [5, 10, 25, 50],

];

Usage

This package will automatically register the ActivityResource class specified in the configuration resource.filament-resource. You'll be able to see it when you visit your Filament admin panel.

Customising the ActivityResource

You can swap out the ActivityResource used by publishing the configuration file and updating the resource.filament-resource value. Use this to create your own ActivityResource class and extend the original at AlexJustesen\FilamentSpatieLaravelActivitylog\Resources\ActivityResource::class. This will allow you to customise everything such as the views, table, form and permissions. If you wish to change the resource on List and View page be sure to replace the getPages method on the new resource and create your own version of the ListPage and ViewPage classes to reference the custom ActivityResource.

Customising the group

You can customise the navigation group for the ActivityResource by publishing the configuration file and updating the resource.group value.

Customising the sorting

You can customise the navigation group for the ActivityResource by publishing the configuration file and updating the resource.sort value.

Relationship manager

If you have a model that uses the Spatie\Activitylog\Traits\LogsActivity trait, you can add the AlexJustesen\FilamentSpatieLaravelActivitylog\RelationManagers\ActivitiesRelationManager relationship manager to your Filament resource to display all of the activity logs that are performed on your model.

Show the subject column on custom relation managers

When using the relationship manager the subject column isn't shown because the subject is the parent record. There are some cases (like when aggregating activities from child records) where the subject might be another record, and you want to show this column. In those cases you can add the next code to your relation manager:

public function hideSubjectColumn(): bool
{
    return false;
}

Testing

composer test

Changelog

Please see RELEASES for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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