HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/app/Providers/StorageServiceProvider.php
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Support\DeferrableProvider;
use App\Library\Storage\StorageInterface;
use App\Library\Storage\StorageEngineResolver;
use App\Library\Storage\LocalStorage;
use App\Model\Setting;
use App\Services\AssetService;

class StorageServiceProvider extends ServiceProvider implements DeferrableProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        // Storage related
        $this->app->bind(AssetService::class);

        $this->app->bind(StorageInterface::class, function ($app) {
            $resolver = $app->make(StorageEngineResolver::class);
            // @important: this is the engine determined by the business
            // not the default engine of Laravel
            $engine = Setting::get('storage.engine');

            return $resolver->resolve($engine);
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        // @important
        // Since this provider is "implements DeferrableProvider"
        // Services MUST be listed here
        // Otherwise, it works in console but not in web
        return [AssetService::class, StorageInterface::class];
    }
}