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];
}
}