Created
November 25, 2019 09:29
-
-
Save AdnanHussainTurki/7eafad43c7e8b6b9ab4a7ebfb2bf41e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter; | |
use Illuminate\Support\ServiceProvider; | |
use League\Flysystem\Filesystem; | |
class GoogleDriveServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Register services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
/** | |
* Bootstrap 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']); | |
$service = new \Google_Service_Drive($client); | |
$adapter = new GoogleDriveAdapter($service, $config['folderId']); | |
return new Filesystem($adapter); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment