| Install | |
|---|---|
composer require alizharb/filament-activity-log |
|
| Latest Version: | v1.3.1 |
| PHP: | ^8.3 |
A powerful, feature-rich activity logging solution for FilamentPHP v4 & v5
Seamlessly track, view, and manage user activities with beautiful timelines and insightful dashboards.
Built on spatie/laravel-activitylog
| Requirement | Version | Status |
|---|---|---|
| 8.3+ | ✅ | |
| 11+ | ✅ | |
| v4+ / v5+ | ✅ |
Dependencies:
composer require alizharb/filament-activity-log
Add to your AdminPanelProvider:
use AlizHarb\ActivityLog\ActivityLogPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
ActivityLogPlugin::make()
->label('Log')
->pluralLabel('Logs')
->navigationGroup('System')
->cluster('System'), // Optional: Group inside a cluster
]);
}
Run the installation command to publish the configuration, assets, and migrations:
php artisan filament-activity-log:install
Ensure your models use the LogsActivity trait:
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;
class User extends Authenticatable
{
use LogsActivity;
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logAll();
}
}
To automatically capture IP addresses and user agent information, add the generic tap to your config/activitylog.php:
'activity_logger_taps' => [
\AlizHarb\ActivityLog\Taps\SetActivityContextTap::class,
],
Navigate to the Logs resource in your admin panel to see all tracked activities.
A dedicated resource allows you to manage all activity logs.
Features:
Visualize the history of any record with a beautiful timeline.
Usage: The timeline is available as a table action in the Relation Manager or can be added to any page.
Displays a line chart showing activity trends over time.
use AlizHarb\ActivityLog\Widgets\ActivityChartWidget;
public function getWidgets(): array
{
return [
ActivityChartWidget::class,
];
}
Shows a list of the most recent activities.
use AlizHarb\ActivityLog\Widgets\LatestActivityWidget;
public function getWidgets(): array
{
return [
LatestActivityWidget::class,
];
}
Add an activity log history table to any of your existing resources (e.g., UserResource).
use AlizHarb\ActivityLog\RelationManagers\ActivitiesRelationManager;
public static function getRelations(): array
{
return [
ActivitiesRelationManager::class,
];
}
The package automatically checks for name, title, or label attributes on your models.
For more control, implement the HasActivityLogTitle interface on your model:
use AlizHarb\ActivityLog\Contracts\HasActivityLogTitle;
class User extends Model implements HasActivityLogTitle
{
public function getActivityLogTitle(): string
{
return "User: {$this->email}";
}
}
Automatically group activities from a single job or request. Use the View Batch action in the Activity Log table to inspect all activities related to a specific batch UUID.
You can customize almost every aspect of the package via the filament-activity-log.php config file.
📚 For detailed configuration instructions, including navigation groups and custom authorization, see CONFIGURATION.md
'table' => [
'columns' => [
'log_name' => [
'visible' => true,
'searchable' => true,
'sortable' => true,
],
// ...
],
],
'widgets' => [
'activity_chart' => [
'enabled' => true,
'days' => 30,
'fill_color' => 'rgba(16, 185, 129, 0.1)',
'border_color' => '#10b981',
],
'latest_activity' => [
'enabled' => true,
'limit' => 10,
],
],
Restrict access to specific users by implementing a custom authorizer invokable class:
// app/Authorizer/ActivityLogAuthorizer.php
namespace App\Authorizors;
class ActivityLogAuthorizer
{
public function __invoke(User $user): bool
{
// Define your custom logic to determine if the user can access the activity log.
return $user->id === 1;
}
}
Then register it in the config:
// config/filament-activity-log.php
'permissions' => [
'custom_authorization' => \App\Authorizer\ActivityLogAuthorizer::class,
],
See CONFIGURATION.md for more examples.
We welcome contributions! Please see CONTRIBUTING.md for details.
# Clone repository
git clone https://github.com/alizharb/filament-activity-log.git
# Install dependencies
composer install
# Run tests
composer test
# Format code
composer format
If this package helps you, consider sponsoring its development:
Your support helps maintain and improve this package! 🙏
This project is licensed under the MIT License - see the LICENSE file for details.