Move CollectionExtension

This commit is contained in:
philipp lang 2024-01-02 23:47:48 +01:00
parent 820a725517
commit 194f1f9c14
2 changed files with 83 additions and 88 deletions

View File

@ -2,13 +2,8 @@
namespace Zoomyboy\MedialibraryHelper;
use Spatie\MediaLibrary\MediaCollections\MediaCollection;
class CollectionExtension
{
public function boot(): void
{
MediaCollection::mixin(new class() {
public function forceFileName()
{
return fn ($callback) => $this->registerCustomCallback('forceFileName', $callback);
@ -92,6 +87,4 @@ class CollectionExtension
]);
};
}
});
}
}

View File

@ -4,6 +4,7 @@ namespace Zoomyboy\MedialibraryHelper;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Spatie\MediaLibrary\MediaCollections\MediaCollection;
class ServiceProvider extends BaseServiceProvider
{
@ -23,7 +24,8 @@ class ServiceProvider extends BaseServiceProvider
$router->patch('mediaupload/{media}', [MediaController::class, 'update'])->name('media.update');
});
app(CollectionExtension::class)->boot();
MediaCollection::mixin(app(CollectionExtension::class));
// app(CollectionExtension::class)->boot();
}
/**