for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Providers;
use Google\Service\Drive;
use Google_Client;
use Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
class GoogleDriveServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
Storage::extend('google', function ($app, $config) {
$client = new Google_Client;
$client->setClientId($config['clientId']);
$client->setClientSecret($config['clientSecret']);
$client->refreshToken($config['refreshToken']);
/** @var \Google\Service\Drive|\Google_Service_Drive $service */
$service = new Drive($client);
$options = [];
if (isset($config['teamDriveId'])) {
$options['teamDriveId'] = $config['teamDriveId'];
}
$adapter = new GoogleDriveAdapter($service, $config['folderId'], $options);
return new Filesystem($adapter);
});