Skip to content

Commit

Permalink
fix: loggable resource registering
Browse files Browse the repository at this point in the history
  • Loading branch information
Z3d0X committed Aug 13, 2023
1 parent c7e4864 commit 1a1c02c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/FilamentLoggerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Z3d0X\FilamentLogger;

use Filament\Facades\Filament;
use Filament\Panel;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
Expand Down Expand Up @@ -47,11 +48,15 @@ public function packageBooted(): void

if (config('filament-logger.resources.enabled', true)) {
$exceptResources = [...config('filament-logger.resources.exclude'), config('filament-logger.activity_resource')];
$removedExcludedResources = collect(Filament::getResources())->filter(function ($resource) use ($exceptResources) {
return ! in_array($resource, $exceptResources);
});

foreach ($removedExcludedResources as $resource) {
$loggableResources = collect(Filament::getPanels())

Check failure on line 52 in src/FilamentLoggerServiceProvider.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined static method Filament\Facades\Filament::getPanels().
->flatMap(fn (Panel $panel) => $panel->getResources())

Check failure on line 53 in src/FilamentLoggerServiceProvider.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to method getResources() on an unknown class Filament\Panel.

Check failure on line 53 in src/FilamentLoggerServiceProvider.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter $panel of anonymous function has invalid type Filament\Panel.
->unique()
->filter(function ($resource) use ($exceptResources) {
return ! in_array($resource, $exceptResources);
});

foreach ($loggableResources as $resource) {
$resource::getModel()::observe(config('filament-logger.resources.logger'));
}
}
Expand Down

0 comments on commit 1a1c02c

Please sign in to comment.