rmsramos / activitylog
This is my package activitylog
Installs: 2 203
Dependents: 0
Suggesters: 0
Security: 0
Stars: 25
Watchers: 1
Forks: 3
Open Issues: 1
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-activitylog: ^4.8
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- filament/filament: ^3.2
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
This package provides a Filament resource that shows you all of the activity logs and detailed view of each log created using the spatie/laravel-activitylog
package. It also provides a relationship manager for related models.
Requirements
- Filament v3
- Spatie/Laravel-activitylog v4
Installation
You can install the package via composer:
composer require rmsramos/activitylog
After that run the install command:
php artisan activitylog:install
This will publish the config & migrations from spatie/laravel-activitylog
You can manually publish the configuration file with:
php artisan vendor:publish --tag="activitylog-config"
This is the contents of the published config file:
return [ 'resources' => [ 'label' => 'Activity Log', 'plural_label' => 'Activity Logs', 'navigation_group' => null, 'navigation_icon' => 'heroicon-o-shield-check', 'navigation_sort' => null, 'navigation_count_badge' => false, 'resource' => \Rmsramos\Activitylog\Resources\ActivitylogResource::class, ], 'datetime_format' => 'd/m/Y H:i:s', ];
Optionally, you can publish the views using
php artisan vendor:publish --tag="activitylog-views"
Usage
In your Panel ServiceProvider active the plugin (App\Providers\Filament)
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make(), ]); }
Customising the ActivitylogResource
You can swap out the ActivitylogResource
used by updating the ->resource()
value. Use this to create your own CustomResource
class and extend the original at \Rmsramos\Activitylog\Resources\ActivitylogResource::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 CustomResource
.
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->resource(\Path\For\Your\CustomResource::class), ]); }
Customising label Resource
You can swap out the Resource label
used by updating the ->label()
and ->pluralLabel()
value.
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->label('Log') ->pluralLabel('Logs'), ]); }
Grouping resource navigation items
You can add a Resource navigation group
updating the ->navigationGroup()
value.
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->navigationGroup('Activity Log'), ]); }
Customising a resource navigation icon
You can swap out the Resource navigation icon
used by updating the ->navigationIcon()
value.
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->navigationIcon('heroicon-o-shield-check'), ]); }
Active a count badge
You can active Count Badge
updating the ->navigationCountBadge()
value.
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->navigationCountBadge(true), ]); }
Set navigation sort
You can set the Resource navigation sort
used by updating the ->navigationSort()
value.
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->navigationSort(3), ]); }
Full configuration
use Rmsramos\Activitylog\ActivitylogPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ ActivitylogPlugin::make() ->resource(\Path\For\Your\CustomResource::class) ->label('Log') ->pluralLabel('Logs') ->navigationGroup('Activity Log') ->navigationIcon('heroicon-o-shield-check') ->navigationCountBadge(true) ->navigationSort(2), ]); }
Relationship manager
If you have a model that uses the Spatie\Activitylog\Traits\LogsActivity
trait, you can add the Rmsramos\Activitylog\RelationManagers\ActivitylogRelationManager
relationship manager to your Filament resource to display all of the activity logs that are performed on your model.
use Rmsramos\Activitylog\RelationManagers\ActivitylogRelationManager; public static function getRelations(): array { return [ ActivitylogRelationManager::class, ]; }
Testing
composer test
Changelog
Please see CHANGELOG 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.