In your .env file
DOCUMENT_INTERFACE=GoogleCloud
#DOCUMENT_INTERFACE=LocalStorage
In my AppServiceProvider.php
use Illuminate\Support\Facades\App;
public function register()
{
$this->app->bind(DocumentInterface::class, function () {
$className = 'Path\To\Interfaces' . '\\' . env('DOCUMENT_INTERFACE') . 'Implementation';
$class = App::make($className);
return new $class();
});
}
DocumentInterface.php
interface DocumentInterface
{
public function create(DocumentUpload $documentUpload);
}
GoogleCloudImplementation.php
class GoogleCloudImplementation implements DocumentInterface
{
public function create(DocumentUpload $documentUpload)
{
}
}
LocalStorageImplementation.php
class LocalStorageImplementation implements DocumentInterface
{
public function create(DocumentUpload $documentUpload)
{
}
}
0 comments:
Post a Comment