Skip to content

Commit df9a2f1

Browse files
committed
feat: release v1.3.1 with multi-panel auth provider fix
- 🛡️ Panel-Aware Causer: Introduced ActivityLogCauser to dynamically resolve user models via current Filament panel guards. - 🚀 Optimized Imports: Cleaned and simplified imports across UserActivitiesPage and ActivityLogTable. - ✅ Verification: 72/72 tests passing, verified logic for multi-auth environments.
1 parent 08e325e commit df9a2f1

File tree

4 files changed

+76
-7
lines changed

4 files changed

+76
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to `filament-activity-log` will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.1] - 2026-02-06
9+
10+
### Fixed
11+
12+
- **Multi-Panel Support** - Fixed an issue where Select filters and causer resolution failed in multi-panel applications using different auth guards.
13+
- Introduced `ActivityLogCauser` support class for dynamic model resolution based on current panel guard.
14+
- Refactored `UserActivitiesPage` and `ActivityLogTable` to use panel-aware causer resolution.
15+
816
## [1.3.0] - 2026-01-31
917

1018
### Added

src/Pages/UserActivitiesPage.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use AlizHarb\ActivityLog\ActivityLogPlugin;
88
use AlizHarb\ActivityLog\Models\Activity;
99
use AlizHarb\ActivityLog\Resources\ActivityLogs\ActivityLogResource;
10+
use AlizHarb\ActivityLog\Support\ActivityLogCauser;
11+
use AlizHarb\ActivityLog\Support\ActivityLogTitle;
1012
use Filament\Pages\Page;
1113
use Filament\Tables\Columns\TextColumn;
1214
use Filament\Tables\Concerns\InteractsWithTable;
@@ -149,13 +151,16 @@ public function table(Table $table): Table
149151
SelectFilter::make('causer_id')
150152
->label(__('filament-activity-log::activity.filter.causer'))
151153
->options(function () {
152-
$model = config('auth.providers.users.model');
154+
$model = ActivityLogCauser::resolveModelClass();
153155

154-
if (! class_exists($model)) {
156+
if (! $model || ! class_exists($model)) {
155157
return [];
156158
}
157159

158-
return $model::query()->pluck('name', 'id')->toArray();
160+
/** @var \Illuminate\Database\Eloquent\Builder $query */
161+
$query = $model::query();
162+
163+
return $query->pluck('name', 'id')->toArray();
159164
})
160165
->searchable()
161166
->preload()
@@ -174,7 +179,10 @@ public function table(Table $table): Table
174179
SelectFilter::make('subject_type')
175180
->label(__('filament-activity-log::activity.filter.subject_type'))
176181
->options(function () {
177-
return Activity::query()
182+
/** @var \Illuminate\Database\Eloquent\Builder $query */
183+
$query = Activity::query();
184+
185+
return $query
178186
->whereNotNull('subject_type')
179187
->distinct()
180188
->pluck('subject_type')

src/Resources/ActivityLogs/Tables/ActivityLogTable.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Filament\Actions\DeleteBulkAction;
1515
use Filament\Actions\ExportAction as FilamentExportAction;
1616
use Filament\Actions\ViewAction;
17+
use AlizHarb\ActivityLog\Models\Activity;
18+
use AlizHarb\ActivityLog\Support\ActivityLogCauser;
1719
use Filament\Facades\Filament;
1820
use Filament\Forms\Components\Checkbox;
1921
use Filament\Forms\Components\DatePicker;
@@ -24,7 +26,6 @@
2426
use Filament\Tables\Table;
2527
use Illuminate\Database\Eloquent\Builder;
2628
use Illuminate\Support\Facades\Gate;
27-
use Spatie\Activitylog\Models\Activity;
2829

2930
/**
3031
* Class ActivityLogTable
@@ -191,12 +192,15 @@ public static function configure(Table $table): Table
191192
SelectFilter::make('causer_id')
192193
->label(__('filament-activity-log::activity.table.filter.causer'))
193194
->options(function () {
194-
$causerClass = config('auth.providers.users.model');
195+
$causerClass = ActivityLogCauser::resolveModelClass();
195196
if (! $causerClass || ! class_exists($causerClass)) {
196197
return [];
197198
}
198199

199-
return $causerClass::query()
200+
/** @var \Illuminate\Database\Eloquent\Builder $query */
201+
$query = $causerClass::query();
202+
203+
return $query
200204
->whereIn('id', Activity::query()
201205
->distinct()
202206
->whereNotNull('causer_id')

src/Support/ActivityLogCauser.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AlizHarb\ActivityLog\Support;
6+
7+
use Filament\Facades\Filament;
8+
use Illuminate\Support\Facades\Auth;
9+
use Illuminate\Auth\EloquentUserProvider;
10+
11+
class ActivityLogCauser
12+
{
13+
/**
14+
* Resolve the causer model class.
15+
*
16+
* In multi-panel applications, it tries to get the model from the current panel's guard provider.
17+
* Falls back to the default Laravel user model configuration.
18+
*
19+
* @return class-string<\Illuminate\Database\Eloquent\Model>|null
20+
*/
21+
public static function resolveModelClass(): ?string
22+
{
23+
if (class_exists(Filament::class)) {
24+
$panel = Filament::getCurrentPanel();
25+
26+
if ($panel) {
27+
$guardName = $panel->getAuthGuard();
28+
$guard = Auth::guard($guardName);
29+
30+
if (method_exists($guard, 'getProvider')) {
31+
/** @phpstan-ignore-next-line */
32+
$provider = $guard->getProvider();
33+
34+
if ($provider instanceof EloquentUserProvider) {
35+
/** @var class-string<\Illuminate\Database\Eloquent\Model> $model */
36+
$model = $provider->getModel();
37+
38+
return $model;
39+
}
40+
}
41+
}
42+
}
43+
44+
/** @var class-string<\Illuminate\Database\Eloquent\Model>|null $model */
45+
$model = config('auth.providers.users.model');
46+
47+
return $model;
48+
}
49+
}

0 commit comments

Comments
 (0)