Feat: Creating Migration Models And Adapters for file Service

This commit is contained in:
2026-09-25 09:10:56 +03:00
parent 69fdd0b4b8
commit 2b8fe5764c
7 changed files with 313 additions and 0 deletions
+34
View File
@@ -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');
}
}