alfasix / alfakit-activity-log
Browse spatie/laravel-activitylog activities in an AlfaKit panel: an activity resource, a relation manager, a timeline entry and action logging.
Requires
- php: ^8.4
- alfasix/alfakit: ^0.1|@dev
- spatie/laravel-activitylog: ^5.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
by Alfa Six
Spatie Laravel Activitylog (v5) for AlfaKit panels: an activity resource, a relation manager, a timeline infolist entry and optional logging of AlfaKit actions. It renders in React, Vue and Svelte with AlfaKit's built-in components.
Installation
composer require alfasix/alfakit-activity-log
Install and migrate spatie/laravel-activitylog, and add LogsActivity to the models you want to log. Then register the plugin:
use AlfaSix\AlfakitActivityLog\ActivityLogPlugin; $panel->plugin( ActivityLogPlugin::make() ->navigationGroup('Settings') ->authorize(fn (User $user): bool => $user->is_admin), );
The log is at /{panel}/activity-log: filters by log name, event, causer, subject type and date, and a view page with the old → new changes and the custom properties.
Usage
use AlfaSix\AlfakitActivityLog\Concerns\LogsAlfakitActions; use AlfaSix\AlfakitActivityLog\Infolists\Components\ActivityLogTimelineEntry; use AlfaSix\AlfakitActivityLog\RelationManagers\ActivitiesRelationManager; // A resource whose model uses LogsActivity: the record's activities as a tab. public static function getRelations(): array { return [ActivitiesRelationManager::class]; } // An infolist timeline of the record's activities. ActivityLogTimelineEntry::make()->limit(20)->columnSpanFull(); // Models without LogsActivity: log AlfaKit's create, edit and delete actions… ActivityLogPlugin::make()->logActions(); // …and resource create / edit pages. class EditInvoice extends EditRecord { use LogsAlfakitActions; }
On panels with tenancy the log only lists the current tenant's activities (scopeToTenant(), scopeToTenantUsing(), recordTenant()).
See the documentation for every option.
License
MIT. See LICENSE.md.