@@ -38,6 +38,7 @@ public function handle(): void
3838 $ this ->art ();
3939 $ this ->welcome ();
4040 $ this ->publishConfiguration ();
41+ $ this ->publishSpatieConfiguration ();
4142 $ this ->publishMigrations ();
4243 $ this ->runMigrations ();
4344 $ this ->registerPluginInPanelProvider ();
@@ -84,6 +85,35 @@ public function publishConfiguration(): void
8485 }
8586 }
8687
88+ public function publishSpatieConfiguration (): void
89+ {
90+ info ('Publishing Spatie Media Library Configuration... ' );
91+ $ this ->callSilent ('vendor:publish ' , [
92+ '--provider ' => 'Spatie\MediaLibrary\MediaLibraryServiceProvider ' ,
93+ '--tag ' => 'medialibrary-config ' ,
94+ '--force ' => true
95+ ]);
96+
97+ $ configPath = config_path ('media-library.php ' );
98+ $ configContent = file_get_contents ($ configPath );
99+
100+ $ configContent = str_replace (
101+ "'media_model' => Spatie \\MediaLibrary \\MediaCollections \\Models \\Media::class " ,
102+ "'media_model' => Moox \\Media \\Models \\Media::class " ,
103+ $ configContent
104+ );
105+
106+ $ configContent = str_replace (
107+ "'path_generator' => Spatie \\MediaLibrary \\Support \\PathGenerator \\DefaultPathGenerator::class " ,
108+ "'path_generator' => Moox \\Media \\Support \\CustomPathGenerator::class " ,
109+ $ configContent
110+ );
111+
112+ file_put_contents ($ configPath , $ configContent );
113+
114+ info ('Updated Spatie Media Library configuration with custom classes. ' );
115+ }
116+
87117 public function publishMigrations (): void
88118 {
89119 if (confirm ('Do you wish to publish the migrations? ' , true )) {
0 commit comments