handleOnDb(); } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); $this->handleOnDb(); } MultiDB::setDB($current_db); } } private function handleOnDb() { set_time_limit(0); //logos Company::cursor() ->each(function ($company) { $company_logo = $company->present()->logo(); if ($company_logo == 'https://invoicing.co/images/new_logo.png') { return; } $logo = @file_get_contents($company_logo); if ($logo) { $path = str_replace("https://objects.invoicing.co/", "", $company->present()->logo()); $path = str_replace("https://v5-at-backup.us-southeast-1.linodeobjects.com/", "", $path); Storage::disk($this->option('disk'))->put($path, $logo); } }); //documents Document::cursor() ->each(function ($document) { $doc_bin = $document->getFile(); if ($doc_bin) { Storage::disk($this->option('disk'))->put($document->url, $doc_bin); } }); //backups Backup::cursor() ->each(function ($backup) { $backup_bin = Storage::disk('s3')->get($backup->filename); if ($backup_bin) { Storage::disk($this->option('disk'))->put($backup->filename, $backup_bin); } }); } }