Feat: Creating Migration Models And Adapters for file Service
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use InvalidArgumentException;
|
||||
use Modules\Core\File\Adapters\LocalFileAdapter;
|
||||
use Modules\Core\File\Contracts\FileAdapterInterface;
|
||||
|
||||
class FileServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
// Same pattern as ShippingServiceProvider's CarrierFulfillmentInterface
|
||||
// binding — a plain param ('disk' here, 'carrier' there) picks which
|
||||
// concrete adapter Modules\Core\File\Services\FileService actually
|
||||
// talks to. Adding a real S3FileAdapter later is one class plus one
|
||||
// more match arm here; nothing that already calls FileService changes.
|
||||
$this->app->bind(FileAdapterInterface::class, function ($app, array $params) {
|
||||
$disk = $params['disk'] ?? 'local';
|
||||
|
||||
return match ($disk) {
|
||||
'local' => new LocalFileAdapter(Storage::disk($disk)),
|
||||
default => throw new InvalidArgumentException("No FileAdapterInterface available for disk \"{$disk}\"."),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user