8
8
use Filament \Support \Assets \Js ;
9
9
use Filament \Support \Facades \FilamentAsset ;
10
10
use Filament \Support \Facades \FilamentIcon ;
11
+ use Illuminate \Database \Eloquent \Relations \Relation ;
11
12
use Illuminate \Filesystem \Filesystem ;
12
13
use Livewire \Features \SupportTesting \Testable ;
13
14
use Spatie \LaravelPackageTools \Commands \InstallCommand ;
14
15
use Spatie \LaravelPackageTools \Package ;
15
16
use Spatie \LaravelPackageTools \PackageServiceProvider ;
16
17
use Statikbe \FilamentFlexibleBlocksAssetManager \Testing \TestsLaravelFilamentFlexibleBlocksAssetManager ;
18
+ use Statikbe \FilamentFlexibleBlocksAssetManager \Models \Asset as AssetModel ;
17
19
18
20
class FilamentFlexibleBlocksAssetManagerServiceProvider extends PackageServiceProvider
19
21
{
@@ -43,6 +45,10 @@ public function configurePackage(Package $package): void
43
45
$ package ->hasConfigFile ();
44
46
}
45
47
48
+ if (file_exists ($ package ->basePath ("/../routes/ {$ configFileName }.php " ))) {
49
+ $ package ->hasRoutes ($ this ->getRoutes ());
50
+ }
51
+
46
52
if (file_exists ($ package ->basePath ('/../database/migrations ' ))) {
47
53
$ package ->hasMigrations ($ this ->getMigrations ());
48
54
}
@@ -85,6 +91,13 @@ public function packageBooted(): void
85
91
86
92
// Testing
87
93
Testable::mixin (new TestsLaravelFilamentFlexibleBlocksAssetManager ());
94
+
95
+ //add Asset to morph map when used:
96
+ if (Relation::requiresMorphMap ()){
97
+ Relation::morphMap ([
98
+ 'filament-flexible-blocks-asset-manager::asset ' => AssetModel::class,
99
+ ], true );
100
+ }
88
101
}
89
102
90
103
protected function getAssetPackageName (): ?string
@@ -99,8 +112,8 @@ protected function getAssets(): array
99
112
{
100
113
return [
101
114
// AlpineComponent::make('laravel-filament-flexible-blocks-asset-manager', __DIR__ . '/../resources/dist/components/laravel-filament-flexible-blocks-asset-manager.js'),
102
- Css::make ('laravel-filament-flexible-blocks-asset-manager-styles ' , __DIR__ . '/../resources/dist/laravel-filament-flexible-blocks-asset-manager.css ' ),
103
- Js::make ('laravel-filament-flexible-blocks-asset-manager-scripts ' , __DIR__ . '/../resources/dist/laravel-filament-flexible-blocks-asset-manager.js ' ),
115
+ // Css::make('laravel-filament-flexible-blocks-asset-manager-styles', __DIR__ . '/../resources/dist/laravel-filament-flexible-blocks-asset-manager.css'),
116
+ // Js::make('laravel-filament-flexible-blocks-asset-manager-scripts', __DIR__ . '/../resources/dist/laravel-filament-flexible-blocks-asset-manager.js'),
104
117
];
105
118
}
106
119
@@ -129,7 +142,9 @@ protected function getIcons(): array
129
142
*/
130
143
protected function getRoutes (): array
131
144
{
132
- return [];
145
+ return [
146
+ 'filament-flexible-blocks-asset-manager ' ,
147
+ ];
133
148
}
134
149
135
150
/**
0 commit comments