Lompat ke konten Lompat ke sidebar Lompat ke footer

Cara memperbaiki error Could not connect to disk google because: ErrorException: Undefined array key "folderId" Laravel 9/10

masalah

Dumping database spatievel...
Determining files to backup...
Zipping 1 files and directories...
Created zip containing 1 files and directories. Size is 6.88 KB
Copying zip failed because: Could not connect to disk google because: ErrorException: Undefined array key "folderId" in C:\Users\farha\Downloads\Compressed\ORI_TIK-Back-End\ORI_TIK-Back-End\app\Providers\GoogleDriveServiceProvider.php:29     

cara mengatasinya, jika isi script coding anda seperti ini

ubah googledriveserverprovider.php

\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 \Masbug\Flysystem\GoogleDriveAdapter($service, $config['folderId']);
            return new \League\Flysystem\Filesystem($adapter);


ubah menjadi 

\Storage::extend('google', function($app, $config) {
            $options = [];

            if (!empty($config['teamDriveId'] ?? null)) {
                $options['teamDriveId'] = $config['teamDriveId'];
            }

            if (!empty($config['sharedFolderId'] ?? null)) {
                $options['sharedFolderId'] = $config['sharedFolderId'];
            }

            $client = new \Google\Client();
            $client->setClientId($config['clientId']);
            $client->setClientSecret($config['clientSecret']);
            $client->refreshToken($config['refreshToken']);
            
            $service = new \Google\Service\Drive($client);
            $adapter = new \Masbug\Flysystem\GoogleDriveAdapter($service, $config['folder'] ?? '/', $options);
            $driver = new \League\Flysystem\Filesystem($adapter);

            return new \Illuminate\Filesystem\FilesystemAdapter($driver, $adapter);


cara tes scedule command kernel laravel sudah berhasil
untuk satu kali putaran 

php artisan schedule:run 

untuk selamanya

php artisan schedule:work