diff --git a/app/Console/Commands/BackupUpdate.php b/app/Console/Commands/BackupUpdate.php index fcd1e6fa04d5..e5bff73c5423 100644 --- a/app/Console/Commands/BackupUpdate.php +++ b/app/Console/Commands/BackupUpdate.php @@ -13,6 +13,7 @@ namespace App\Console\Commands; use App\Libraries\MultiDB; use App\Models\Backup; +use App\Models\Company; use App\Models\Design; use Illuminate\Console\Command; use Illuminate\Support\Facades\Storage; @@ -25,14 +26,14 @@ class BackupUpdate extends Command * * @var string */ - protected $signature = 'ninja:backup-update'; + protected $signature = 'ninja:backup-files {--disk=}'; /** * The console command description. * * @var string */ - protected $description = 'Shift backups from DB to storage'; + protected $description = 'Shift files between object storage locations'; /** * Create a new command instance. @@ -74,17 +75,30 @@ class BackupUpdate extends Command { set_time_limit(0); - Backup::whereHas('activity')->whereRaw('html_backup IS NOT NULL')->cursor()->each(function ($backup) { - if (strlen($backup->html_backup) > 1 && $backup->activity->invoice->exists()) { - $client = $backup->activity->invoice->client; - $backup->storeRemotely($backup->html_backup, $client); - } elseif (strlen($backup->html_backup) > 1 && $backup->activity->quote->exists()) { - $client = $backup->activity->quote->client; - $backup->storeRemotely($backup->html_backup, $client); - } elseif (strlen($backup->html_backup) > 1 && $backup->activity->credit->exists()) { - $client = $backup->activity->credit->client; - $backup->storeRemotely($backup->html_backup, $client); - } - }); + //logos + + Company::query() + ->cursor() + ->each(function ($company){ + + $logo = @file_get_contents($company->present()->logo()); + + if($logo){ + + $path = str_replace("https://object.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 + + + //backups + } } diff --git a/app/Http/Requests/User/UpdateUserRequest.php b/app/Http/Requests/User/UpdateUserRequest.php index e09f86d3fff6..8c1cae259bf5 100644 --- a/app/Http/Requests/User/UpdateUserRequest.php +++ b/app/Http/Requests/User/UpdateUserRequest.php @@ -68,6 +68,9 @@ class UpdateUserRequest extends Request if(array_key_exists('phone', $input) && strlen($input['phone']) > 1 && ($this->user->phone != $input['phone'])) $this->phone_has_changed = true; + if(array_key_exists('oauth_provider_id', $input) && $input['oauth_provider_id'] == '') + $input['oauth_user_id'] = ''; + $this->replace($input); } diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index cecc25522b2f..49f6918c7c4c 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -56,8 +56,8 @@ class UserRepository extends BaseRepository $company = auth()->user()->company(); $account = $company->account; - if(array_key_exists('oauth_provider_id', $details)) - unset($details['oauth_provider_id']); + // if(array_key_exists('oauth_provider_id', $details)) + // unset($details['oauth_provider_id']); if (request()->has('validated_phone')) $details['phone'] = request()->input('validated_phone');