name('filament') ->hasCommands([ AssetsCommand::class, CheckTranslationsCommand::class, InstallCommand::class, UpgradeCommand::class, ]) ->hasConfigFile() ->hasTranslations() ->hasViews(); } public function packageRegistered(): void { $this->app->scoped( AssetManager::class, fn () => new AssetManager(), ); $this->app->scoped( ColorManager::class, fn () => new ColorManager(), ); $this->app->scoped( IconManager::class, fn () => new IconManager(), ); $this->app->scoped( ViewManager::class, fn () => new ViewManager(), ); $this->app->scoped( HtmlSanitizerInterface::class, fn (): HtmlSanitizer => new HtmlSanitizer( (new HtmlSanitizerConfig()) ->allowSafeElements() ->allowRelativeLinks() ->allowRelativeMedias() ->allowAttribute('class', allowedElements: '*') ->allowAttribute('style', allowedElements: '*') ->withMaxInputLength(500000), ), ); } public function packageBooted(): void { FilamentAsset::register([ Js::make('async-alpine', __DIR__ . '/../dist/async-alpine.js'), Css::make('support', __DIR__ . '/../dist/index.css'), Js::make('support', __DIR__ . '/../dist/index.js'), ], 'filament/support'); Blade::directive('captureSlots', function (string $expression): string { return "mapWithKeys(fn (string \$slot): array => [\$slot => \$slotContents[\$slot] ?? null])->all(); unset(\$slotContents) ?>"; }); Blade::directive('filamentScripts', function (string $expression): string { return ""; }); Blade::directive('filamentStyles', function (string $expression): string { return ""; }); Str::macro('sanitizeHtml', function (string $html): string { return app(HtmlSanitizerInterface::class)->sanitize($html); }); Stringable::macro('sanitizeHtml', function (): Stringable { /** @phpstan-ignore-next-line */ return new Stringable(Str::sanitizeHtml($this->value)); }); if (class_exists(InstalledVersions::class)) { $packages = [ 'filament', 'forms', 'notifications', 'support', 'tables', ]; AboutCommand::add('Filament', static fn () => [ 'Version' => InstalledVersions::getPrettyVersion('filament/support'), 'Packages' => collect($packages) ->filter(fn (string $package): bool => InstalledVersions::isInstalled("filament/{$package}")) ->join(', '), 'Views' => function () use ($packages): string { $publishedViewPaths = collect($packages) ->filter(fn (string $package): bool => is_dir(resource_path("views/vendor/{$package}"))); if (! $publishedViewPaths->count()) { return 'NOT PUBLISHED'; } return "PUBLISHED: {$publishedViewPaths->join(', ')}"; }, ]); } if ($this->app->runningInConsole()) { $this->publishes([ $this->package->basePath('/../config/filament.php') => config_path('filament.php'), ], 'filament-config'); } } }